I have a text file as such:
Attribute 1.............. : attribute value
Encode Date............................. : JUL 2007
Attribute 22076.......... : attribute value`
I want to extract the JUL 2007
segment but only when it is preceded by Encode Date
as JUL 2007 might appear elsewhere in the file.
This regex below works when tested at regexr.com with the PHP interpreter with global and multi-line mode enabled:
(?<=Encode Date............................. : ).*$
But running this command gives me no output, what am I missing?
cat file.txt | awk '/(?<=Encode Date............................. : ).*$/{print $0}'
match
function asmatch($0,/PATTERN/) > 0 {print substr($0,RSTART+RLENGTH)}
– steeldriver Mar 16 '19 at 23:19index()
and use the search string's length of course... But it's much too fiddly for what they appear to want to do. – Kusalananda Mar 16 '19 at 23:27