简体   繁体   中英

How to show #s in vertical from Horizontal through simple regex?

I have the following numbers as shown below:

1234567890

I would like to get the result as:

1
2
3
4
5
6
7
8
9
0

(Horizontal to Vertical). Please help me to achieve it via simple regex or through editplus.

Thanks in advance !!!

You don't need a regular expression for this; all you're trying to accomplish is to insert a newline character between each element in your string.

If you're using C#, you can use the following:

string s = "1234567890";
string.Join(Environment.NewLine, s.ToCharArray());

Note that if your number is of a numeric data type (eg, int ), you'll likely need to convert it to a string. In C#, this is as simple as calling the .ToString() method, for example:

int x = 1234567890;
string s = x.ToString();

sorry I don't have editplus, but this should work (tested in notepad++)

Find:

([0-9])

replace:

\1\r\n

make sure to have regular expression search on (this may only pertain to notepad++)

the () creates a regular expression group, that may then be back referenced via the "\\1" (see the link for a primer) the "\\r\\n" are just CRLF

Replace . with &\\n in editplus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM