I am trying to capture the text between 2 delimiters only when there is also a line feed within the delimiters. So for example if we have the following text.
Organisation Name <<me.company.name>>
ABN/ACN <<me.company.abn>>
Contact Name <<me.name>>
<<me.PhoneNumber
Another line>>
Email <<me.emailAddress>>
I am wanting to only return the <<me.PhoneNumber \n\n 'Another Line>>
the \n could be anywhere - basically only matches that have at least one \n within the << >> and ignore all other << >>
The pattern I have so far is <<(.?\n)*?>> but this captures all << >> (I'm using C#)
here is an example of what I have tried https://regex101.com/r/sb0wCs/1
Thanks so much for your help
You can use
<<((?:(?!<<|>>).)*?\n(?s:.)*?)>>
See the regex demo. Details:
<< - a << string((?:(?!<<|>>).)*?\n(?s:.)*?) - Group 1:
(?:(?!<<|>>).)*? - any zero or more chars (other than newline chars) that do not start >> or << char sequence, as few as possible\n - a LF char(?s:.)*? - any zero or more chars (including newline chars), as few as possible>> - a >> stringIf 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