[Vienna-pm] Regex Frage
Peter J. Holzer
hjp-vienna-pm-list at hjp.at
Wed Jun 13 08:44:58 PDT 2007
On 2007-06-13 15:34:51 +0200, Marinos Yannikos wrote:
> Karlheinz schrieb:
> > Maros Kollár wrote:
> > > Gibt es eine Möglichkeit dass der Inhalt der Variable '$prefix' nicht
> > > als Regular Expression sondern als einfacher String behandelt wird?
> >
> > jo, gibt's - \Q$foo\E :
> >
> > $string =~ m/^\Q$prefix\E+\s(irgend)?eine\slange,\s*blöde\s[Rr]egexp$/;
> >
> Da gibt's aber AFAIR einen kleinen Fallstrick, steht auch irgendwo in
> den manpages - der String sollte dann kein "\" als letztes Zeichen haben.
Nein, \E wird vor der Variableninterpolation ausgewertet (perldoc perlop
/Gory details of parsing quoted constructs /Interpolation). Sonst
könnte man ja einfach ein \E in die Variable einschmuggeln und damit das
Quoting aushebeln.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp at hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.pm.org/pipermail/vienna-pm/attachments/20070613/551a9ef1/attachment.bin
More information about the Vienna-pm
mailing list