PaulG
PaulG

Reputation: 7142

.net using regex to extract a pattern from a string

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.

Upvotes: 0

Views: 228

Answers (1)

David B
David B

Reputation: 2698

(\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.

Upvotes: 1

Related Questions