regex - How to match a field in the middle or the end of a line with separators? -
sorry title, don't know how explain problem in 1 sentence.
i'm trying match field in log don't know if it's in middle of line or @ end of it.
example 3 lines:
b=this short sentence c=see a=hello world c=see b=this short sentence a=hello world a=hello world b=this short sentence c=see
i'd value of "c" field (see soon). problem last line, there no separator @ end of string.
this tried.
this 1 doesn't match last line it's last field:
c=([^=]+) \w+=
this 1 works looks over-complicated:
c=([^=]+)(?: \w+=|$)
how this?
you regex fine, have simplified beginning:
c=.*?($|\n|(\w=))
you can try out here: https://regex101.com/r/on8cs2/1
Comments
Post a Comment