in reply to how can I use regular expresion if my string to be matched has round brackets
In fact, quotemeta and \Q\E will actually transform a string usefully (so you can see what escapes to use for next time):if( m/(\()/ ) { print "I matched a paren: $1\n"; }
UPDATE: I thought quotemeta was smarter than s/(\W)/\\$1/g. count me underwhelmed. I did wonder why it was escaping spaces.print "\Qhrm, do I have to escape dots (.) and question marks?\E\n";
-Paul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how can I use regular expresion if my string to be matched has round brackets
by JavaFan (Canon) on Oct 06, 2008 at 15:23 UTC | |
by moritz (Cardinal) on Oct 06, 2008 at 15:35 UTC | |
|
Re^2: how can I use regular expresion if my string to be matched has round brackets
by advait (Beadle) on Oct 06, 2008 at 15:22 UTC |