Let's say I have
def
abc
xyz
abc
And I want to match
xyz
abc
as a whole
Is this possible using the most generic RegEx possible? That is not the perl RegEx or .Net Regex which have multi line flags.
I guess it would be BNF to match this.
Many regex implementations allow explicit line terminators. If \n is the line separator, then just search for xyz\nabc
.
Regexes work on whatever text you give them, multiline or otherwise. If it happens to contain linefeeds, then it's nominally "multiline" text, but you don't have to do anything special to match it with regexes. Linefeed is just another character.
The name "multiline flag" (or "multiline mode") confuses many people. All that flag does is change the meaning of the ^
and $
anchors, allowing them to match at the beginning and end of logical lines as well as the beginning and end of the whole text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With