in reply to RE: RE: Re: Backslashes in regular expressions
in thread Backslashes in regular expressions
If anyone's interested, I finally got it figured out to my own satisfaction. The problem stems from the placement of the + multiplier, if you place it as I did originally (reduced to it's simplest form):
Then the original (\\) matches at least one \. This is then muliplied any number of times and followed by a single \ (since that's what the () stored). The effect of this is to match any number more than one. What you actually need is:/(\\)+\1/
This matches at least one, but possibly more \, this group of \s are then stored as the backreference and the whole expression will only match if there are an even number of \s. :-)/(\\+)\1/
It all seems a lot simpler now that I've got it figured out, it just didn't seem that way when I was working through it.
Thanks for Reading
Nuance badly copying Simplicus
|
|---|