Regex plugin pet-hate
I have a new minor pet-hate with the regex plugin.
When selecting the "copy regex to java string" option, the pasted string
ALWAYS includes a carriage return, so I end up having to manually
backspace/del it to get my code on the same line again.
Mark
Please sign in to leave a comment.
This is with a single line regex I take it? I tend to end out with
multi line ones and so hadn't noticed this. It's easy enough to fix,
I'll see to it.
Guy
Mark Derricutt wrote:
Guy Gascoigne-Piggford wrote:
Single liners yeh... Havn't really had the need to tackle a multiliner
yet ( thank god ).
--
Discouragement is a dissatisfaction with the past, a distaste for the
present, and a distrust of the future - Maree De Jong, CLCA.
Mark Derricutt --- mark@ talios.com --- http://www.talios.com
To be honest there isn't anything that you actually NEED the multiline
pattern for. It's exactly the same syntax but it allows you to add
comments in the expression, I tend to find that something like this:
"(?: \n" +
" # First look for a non-escaped quote character \n" +
" (?:(?<!
)\") \n" +
" # Then look for the string contents \n" +
" (.*?) \n" +
" # Finish with a closing non-escaped quote \n" +
" (?:(?<!
)\") \n" +
" # The allow this sequence to be repeated with plus \n" +
" # signs joining the strings \n" +
" (?:
s*
+
s) \n" +
") \n",
(which looks for multi-line strings and is used in the regex tool to
convert from a java string when pasting from the clipboard) is much
easier to read when I come back to it after a few months than this:
"(?:(?:(?<!
)\")(.?)(?:(?<!
)\")(?:
s
+
s))"
which does the same thing and is more compact.
So basically it's a matter of taste :)
Guy
Mark Derricutt wrote:
>> This is with a single line regex I take it? I tend to end out with
>> multi line ones and so hadn't noticed this. It's easy enough to fix,
>> I'll see to it.