I have:
a
b
c
d
e
on my clipboard, but this doesn't remove the newline. Any idea why?
It's multi-line text, so you need (?m)
at the front of your regex, and it should work.
-rob.
It works for me. Do you have “All matches” ticked under the cog menu? (This is the default).
Is your input text plain text? Why are the first two characters in red?
You’ve probably already resolved your issue with griffman's suggestion, but I just wanted to add that \R
is generally recommended because it matches a wider range of newline characters:
Regex Pattern | Description |
---|---|
\R |
Match a new line character, or the sequence CR LF. The new line characters are \u000a, \u000b, \u000c, \u000d, \u0085, \u2028, \u2029 |
That shouldn't matter, there are no anchors in the pattern to switch the behaviour of.
Auto syntax colouring in the code block, I believe.
Works here:
...so I suspect you've got a rogue space or other invisible character after your pattern -- triple-click on [\n\r]
and see if the selection extends past the +
.
You may have accidentally set the action's options to "Last Match", but I suspect you'd see that when you pasted.
Or it could be that whatever is on your clipboard isn't being properly reproduced in a Forum code block.
If still stuck, post a minimal macro, with the text in a variable, that demonstrates the problem -- we can't get any further without knowing your actual text and action.
Doh, my bad!
-rob.
Nailed it!!! Thanks @Nige_S -- it was John Error!
I had [\n\r]+<newline>[\n\r]+
I only discovered it because I cursored from the beginning to the end checking for white spaces and it WRAPPED to what I thought was the beginning of the line.
Triple-clicking comes in handy here because it selects the entire contents of the field. So this is good:
...while this has some extra spaces on the end:
and when the entire field is highlighted
...you almost certainly have a line-break in there.
Fun fact. I wrote the code that selects text ranges via single / double / triple click / shift click ranges, etc... for many of Apple's apps.