如何通过简单的正则表达式从水平方向垂直显示#s?
我有以下数字,如下所示:
1234567890
我想得到的结果为:(
1
2
3
4
5
6
7
8
9
0
水平到垂直)。请帮助我通过简单的正则表达式或通过 editplus 来实现它。
提前致谢 !!!
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 !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为此,您不需要正则表达式;您想要完成的只是在字符串中的每个元素之间插入换行符。
如果您使用的是 C#,则可以使用以下内容:
请注意,如果您的号码属于数字数据类型(例如
int
),您可能需要将其转换为字符串。在 C# 中,这就像调用.ToString()
方法一样简单,例如: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:
Note that if your number is of a numeric data type (e.g.,
int
), you'll likely need to convert it to a string. In C#, this is as simple as calling the.ToString()
method, for example:抱歉,我没有editplus,但这应该可以工作(在记事本++中测试)
查找:
替换:
确保进行正则表达式搜索(这可能仅适用于记事本++)
()创建一个正则表达式组,然后可能是通过“\1”反向引用(请参阅入门链接)
“\r\n”只是 CRLF
sorry I don't have editplus, but this should work (tested in notepad++)
Find:
replace:
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
在 editplus 中将
.
替换为&\n
。Replace
.
with&\n
in editplus.