简体   繁体   English

如何通过简单的正则表达式从水平显示垂直#s?

[英]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. 请帮我通过简单的正则表达式或通过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: 如果您使用的是C#,则可以使用以下内容:

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. 请注意,如果您的数字是数字数据类型(例如, int ),您可能需要将其转换为字符串。 In C#, this is as simple as calling the .ToString() method, for example: 在C#中,这就像调用.ToString()方法一样简单,例如:

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

sorry I don't have editplus, but this should work (tested in notepad++) 对不起,我没有editplus,但这应该工作(在记事本++中测试)

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 ()创建一个正则表达式组,然后可以通过“\\ 1” 反向引用 (参见引言的链接)“\\ r \\ n”只是CRLF

Replace . 替换. with &\\n in editplus. 使用&\\n plus在editplus中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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