|
hi amit --
In a message dated 4/5/2006 10:21:02 A.M. Eastern Standard Time,
[EMAIL PROTECTED] writes:
> Hi ,
> Just need a bit help.. > How do i every of the + sign from my document. > its like my documnet has the words in the format as: > > G+Chdgf {every line has only word in it} > HC4+ > +djd > hffd+hdd > > how do i remove the + signs from these......? > Can you help me out there are two ways to handle regex metacharacters in strings:
use the function quotemeta() (see ``perldoc
-f quotemeta'' below);
use the \Q escape in the regex just before the string in which
metacharacters may
be found, e.g.,
my $string = 'this+that'; # string
with potential regex metacharacter
if ($another_string =~ m( \Q$string\E
)x) { # is string found in another string?
# do stuff...
}
(the \E escape ends escaping of potential
metacharacters in interpolated strings.)
(see perldoc -q "how can i quote a variable to use in a
regex?")
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 $_.
hth -- bill walters
|
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
