Regex not working

According to https://regex101.com/r/GxyvER/4 my Regex is correct.
However it doesn't work correctly in KM.

In KM the 2nd Capture group only gets up to the first line break when it should get all remaining text.

Any ideas how to fix?

JeanTrogger.rtf.zip (1.7 KB)

You have the s flag set at regex101.com, but not in KM, so the . character matches newlines at the former, but not the latter. Try modifying the regex in KM to

(?s)([^\n]*)\n+(.*)

so that it includes the flag there as well and it should work.

This works - thanks. The only problem I have is that some of the source text is “formatted” e.g. bolded. The formatting is lost. Are there any tricks to do the regex but retain the source formatting?

If one of the above posts solves your problem/question as originally stated, please check the “Solved” checkbox (click for details) at the bottom of that post.

Otherwise, please post your remaining questions/issues about this problem.
If you have other questions, please start a new topic.

I’ll use your post to start a new topic.

A post was merged into an existing topic: How Do I Use RegEx on RTF Text and Retain Formatting?