I have a string that can contain any number of any type of characters. I'm looking to use regex to extract patterns and put them into a String that I can later manipulate.
我有一个字符串,可以包含任意数量的任何类型的字符。我正在寻找使用正则表达式来提取模式并将它们放入一个我以后可以操作的字符串中。
Ex: I want regex to extract all 3 digit sequences. So if I have a string that says "Easy as 123" I would get "123" from it.
例如:我希望正则表达式提取所有3位数序列。所以,如果我有一个字符串上写着“Easy as 123”,我会从中得到“123”。
BTW This is for C#.net and VB.net
BTW这适用于C#.net和VB.net
Thanks a lot.
非常感谢。
1 个解决方案
#1
1
(\d+)
( start capturing group
\d capture digits
+ capture one or more
) end capturing group
That will extract digits. But I recommend you read up on regex so you can learn the conventions and write your own. Try using regexr to test them too.
这将提取数字。但我建议你阅读正则表达式,这样你就可以学习这些约定并编写自己的约定。尝试使用regexr来测试它们。
#1
1
(\d+)
( start capturing group
\d capture digits
+ capture one or more
) end capturing group
That will extract digits. But I recommend you read up on regex so you can learn the conventions and write your own. Try using regexr to test them too.
这将提取数字。但我建议你阅读正则表达式,这样你就可以学习这些约定并编写自己的约定。尝试使用regexr来测试它们。