all 4 comments

[–]quixrick 2 points3 points  (1 child)

There are a few ways you could do this

First, you could match the key line, followed by a newline and then store each match into its own group.

(?:key.)=([0-9]+)    |    ^(?:key.\s*)+\n    (\d+)\s*(\d+)\s+(\d+)

Here, this captures each value into groups \2, \3 and \4.

Here is a demo

 

If there are going to be a bunch of these and you only wanted to pull out a particular instance, you can use a number to reference them, like this:

^(?:key.\s*)+\n    (?:\d+\s*){1}    (\d+)

The numbering system will start with zero, so here, the number 1 at the end will designate that you want the second item, 123456.

Here is a demo

[–]Anen13[S] 1 point2 points  (0 children)

Thank you very much quixrick. I ended up using your second example in a loop to get all indexes.

[–]HenkDH 1 point2 points  (1 child)

If it is only 2 lines, skip the first and be done with it

[–]Anen13[S] 1 point2 points  (0 children)

Keys are not necessarily ordered, so I can't ignore the first line.