omega
omega

Reputation: 43943

How to extract strings from regular expression?

If you have a regular expression like test\(\d+,[a-z]+\). And it matches with some string, how can you extract the strings which matched \d+ and [a-z]+.

Note: the above was a simple example, the solution should work for any cases.

Upvotes: 0

Views: 47

Answers (1)

Blender
Blender

Reputation: 298532

Add capturing groups:

test\((\d+),([a-z]+)\)

Upvotes: 1

Related Questions