I need to produced a named capture of numbers in a list
Example Source Data
This is a comment on line 1
Here is another Comment Line 2
Log ID 1234,5555,2342
using: (?<id>(\d+)*) I will pick up the results of
1
2
1234
5555
2342
But this picks up 1 and 2 in error. I need it to pick up the items after Log ID Only.
I am looking for a regular expression that will return
1234
5555
2342
In a named group called id
If your language supports variable length lookbehinds, you should be able to use the following:
I also made some modifications to your original regex, because I don’t really see the point of the additional capture group inside of the named capture group, or the nested repetition (
(\d+)*is equivalent to(\d*), but I think you actually want\d+so that it requires you to match at least one digit).If you can’t use variable length lookbehinds (most languages), then you will probably need to do this in two steps. First match any lines with ‘Log ID’ then look for numbers in those lines.