I’m looking for a regex statement to verify a string is exactly 2 lines. I’m using the .Net regex syntax.
I want to make sure that the whole input string is included. I assume I’ll need the \A and \Z markers at the start and end of my expression. I’m also using the Unicode line boundaries of (\r\n|[\n\v\f\r\x85\u2028\u2029]).
So far I have created the follow. Although it does not work as expected.
\A.+?(\r\n|[\n\v\f\r\x85\u2028\u2029])[^\n\v\f\r\x85\u2028\u2029]+?\1?\Z
Example input
Match
some line
other line
No match
some line
other line
this is incorrect input
The line can have an optional new line character after the last line. As long as it doesn’t have any text.
just read your last bit, you can have optional new line at the end with