|
In a message dated 8/21/2006 5:48:44 A.M. Eastern Standard Time,
[EMAIL PROTECTED] writes:
> <part of html code><a
href="">> >> <a
href="" title="ID = 31"
> >OMnMusi y~</a><h2> OMnMusi y~</h2>_JPHo1d77b0!D$MwxhzXL$WQZ2bFX!M3dbzjiDYROglF_w9sKr4cPSPvCYEDv5ElZ56S0EMJ_$LHHzuxKvYrJnzRLwrxRiiRukNu > </part of html code>here is part of the perl code :$title = "OMnMusi y~";$content = "_JPHo1d77b0!D$MwxhzXL$WQZ2bFX!M3dbzjiDYROglF_w9sKr4cPSPvCYEDv5ElZ56S0EMJ_$LHHzuxKvYrJnzRLwrxRiiRukNu"; > I wanna use ~m#<a href="" match it to check if the HTML works right. > but "$","&","*",etc will be translated into part of the regex.This is really a trouble.I wanna use ~s///g to add a "\" before those charactor.But it seems don't work. > Could anyone help?Thanks a lot~! > try using quotemeta() function:
perldoc -f quotemeta
quotemeta EXPR
quotemeta Returns the value of EXPR with all non-"word" characters backslashed. (That is, all characters not matching "/[A-Za-z_0-9]/" will be preceded by a backslash in the returned string, regardless of any locale settings.) This is the internal function implementing the "\Q" escape in double-quoted strings. If EXPR
is omitted, uses $_.
C:[EMAIL PROTECTED]>perl -we "use strict; my $hasmeta =
'a$b*c+d?e\f^';
my $nometa = quotemeta $hasmeta; print $nometa;" a\$b\*c\+d\?e\\f\^ hth -- bill walters
|
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
