Cairoo wrote: ↑Thu Apr 06, 2023 6:37 pm
Indeed the correct regex. It still bugs me that LiveCode wrongly interprets "\r" as "\n", though.
could this have something to do with the fact the line ending could be: \r, \n, or \r\n?
are you sure your \r isn't picking up \r\n?
If you are convinced your regex is correct test it out on
https://regex101.com, and you'll be able to see what exactly is being captured... it also has a hand set of features like a quick reference, hovering over tokes in your expression tells you what they do etc.
For what it's worth I practically never need nested replaceText or findText messages - regex is an incredibly flexible language that can manage all of that, but not easy to use; this website lets me tinker with regex until I get it to do what I want with a single statement...
S.
PS: in your example you nest two replaceText commands but that's unnecessary - all you need to do is replace 2 consecutive line endings with one. There is a scenario where the 'empty' line may have for example tabs in it - if you have records in TSV format but the fields of one record are all empty. The text will will just show line->empty line->line but in reality it's line->(tab tab tab)->line so important to guard for that.
Filter lines does this for you but the regex I post above will as well.