Going mad trying to figure this out - how do I select a regex capture group?

There is some text I'm selecting which goes something like this: Name: John Doe Age: 23. I am trying to extract name and age. Here are my regex expressions:

Name:
Name: ([A-z ]+)

Age:
Age: (\d+)

However, both the Name: and Age: text appears. How do I get rid of this? I thought enclosing it in a captrue group would help, but it's doesn't work at all!

For this case, you would need a "positive lookbehind". the lookbehind is only used for matching, and it won't be captured.

(?<=Name: )[A-Za-z ]+

1 Like

Awesome, that kind of makes sense. Thanks a lot. This seems like a bit of a workaround though. Is there any way to achieve this using capture groups? It sounds like it would be much simpler just to capture the first group using $1.

In regex, capture groups are mainly used for find-n-replace operations. WS currently does not support regex replace, it only does regex match (find).

Ah I see. I think I was misunderstanding regex. Thanks