Reputation: 151
I am working on a regular expression problem and have run into some issues when I try to match text between certain markers. Below is a regular expression tester with what I have completed so far.
https://regex101.com/r/gE8uQ1/1
I am trying to select the ALL of the query text which appears after "statement: " and before the \nTIMESTAMP. I have used \n\d{4}-d{2}-d{2} to represent the timestamp, but it will not select the whole query. Why is this happening? Is it because of my modifiers?
Upvotes: 0
Views: 174
Reputation: 67968
(?<=statement: )([ _\-|0-9,:;\.=A-Za-z\(\)"\n\t']+?)(?=(?:\d{4}-\d{2}-\d{2}|$))
Try this.See demo.Just change your negative lookahead
to positive lookahead
and add quantifier
to character class
.
See demo.
https://regex101.com/r/gE8uQ1/5
Upvotes: 1
Reputation: 13640
You can use the following with g
and s
(because your querys have new lines which are not matched by .
) modifiers:
(?<=statement: )([ _\-|0-9,:;\.=A-Za-z\(\)"\n\t'].+?)(?=\d{4}-\d{2}-\d{2}|$)
^ ^ ^
See DEMO
Upvotes: 0