
davorg
Thaumaturge
/ Moderator
Jan 10, 2004, 11:36 AM
Post #2 of 3
(1104 views)
|
|
Re: [jck7777] help with regular expression
[In reply to]
|
Can't Post
|
|
$Form{$sorted_field} =~ s/\r\n/\s/g; I expected this expression to replace newline characters with whitespace. What it does is replace newline characters with an s. So I thought, perhaps I should escape the "\s" special character with another \, that just replaces the newline characters with a \ and an s. \s stands for a whitespace character in a regular expression. The right hand part of the substitution operator (the replacement string) is _not_ a regular expression, it's treated as a double-quoted string. Therefore you can't use regex escape sequences in the replacement string. Just use whatever character you want the replacement to be.
$Form{$sorted_field} =~ s/\r\n/ /g; -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|