1

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.

BTW This is for C#.net and VB.net

Thanks a lot.

1 Answer 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.

3
  • Thanks. Will do. Regex is not my strong point. I appreciate the help.
    – PaulG
    Jun 1, 2012 at 18:55
  • @PaulG You can browse the regex tag here on SO to get a feel for more complex regexs to aid your understanding. Good luck. (If the answer helped, make sure to hit the green check mark to accept it)
    – David B
    Jun 1, 2012 at 18:57
  • 1
    Thanks. I would accept the answer but I have to wait 8 minutes
    – PaulG
    Jun 1, 2012 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.