I've got such text:
0000 10 [STUFF] Text ("TOTAL,SOME RANDOM TEXT") (558b6a68)
The first two column is pretty static. The third is optional. The last is optional and if exists, then always covered between parenthesis.
My issue is with the forth column, which can have spaces or actually any character inside (except newline of course).
My current regex looks like this:
^([a-fA-F0-9]{4,})\s+[a-fA-F0-9]+\s+(?:\[[^\]]*\]\s+)?
It matches all until the beginning of the fourth column.
Please note that space might exist anywhere, I can't define exact locations, like "always before parenthesis" or "may be between quotation marks".
I know for sure that this is the column before the last. So I'd like to capture them like this:
0000 10 [STUFF] Text("TOTAL,SOME RANDOM TEXT") (558b6a68)
^ ^ ^ ^ ^ ^
CAPTURE C A P T U R E C A P T U R E
I'd like to capture the texts marked between ^ ^ characters mentioned in the previous code block.
So, I'd like to grab any character UNTIL the last bunch of whitespace but also I don't want to include them into the final match group.
I hope I described it well :) Is it posssible with regex at all?
Here is some more sample text to test on:
0000 10 Text("TOTAL,SOME RANDOM TEXT") (1122aabb)
0010 5 D==1122aabb (1122aabb)
0015 17 Text("AND,SOME,MORE") (00000001)
002c 5 D==1 (1)
0031 1 !D (ccdd3344)
0032 5 D==ccdd3344 (ccdd3344)
0037 2 !1 (1)
0039 0 [AAAA] Fff
0039 1 [BBBB] Aaa
003a 6 N(05, eeff5566) (eeff5566)
0040 1 Qq
0041 2 $ab ([String]:"Unknown")
0043 f Call A/SomeFunc-X
0052 1 cd
I'd also start similar like your pattern with something like ^(\w+) +\w+ +(?:\[[^\]]+\] *)?
From here (start of 4th column) capture the first \S
non white space followed by .*?
lazily any amount of any character until an optional parenthesized part at the $
end can be captured. If not, the full line is consumed by group two.
^(\w+) +\w+ +(?:\[[^\]]+\] *)?(\S.*?)(?: +(\([^)]+\)))?$
Feel free to adjust the parenthesis of the third group to only capture what's inside if needed.