Home > Software design >  After x groups of spaces select the next bunch of chars - regex
After x groups of spaces select the next bunch of chars - regex

Time:02-12

I need help creating a reflex expression.

I have a file/string with a lot of lines, but I've only listed the first two as these are the only ones that matter. The value I am trying to extract is from the second line only and is the 5th group along; in this case it will the 2nd number 8. As you can see though, the first three bunches of chars are not words. The brackets are colour codes and need to stay there. There may also be another string further down like the second row, I need it to return the first value only (not multiple matches).

[56f442] M    WS  BS   S   T    W    A  Ld  Sv   [-]
[98ffa7]12"[-]   [98ffa7]3 [-]   [98ffa7]3 [-]   8   8   26   4   9   3    [-][-]

Thanks

CodePudding user response:

To capture the group of non-whitespace (\S ) after the 4th group (?:\S \s ){4} that's after the first newline ^.*?\n.*?

^.*?\n.*?(?:\S \s ){4}(\S )
  • Related