in reply to Re: regex incorrectly matching newline
in thread regex incorrectly matching newline
Well, after you asked the question I looked back at the code and found it actually looked like the follow (more code context included):
$buf = "hello\nworld"; $l = length($buf); for ($x = 0; $x < $l; $x++) { $piece = substr($buf, $x, 1); $i = ord($piece); if ($i =~ m/[ -~]/) { $rhs .= $i; } else { $rhs .= "."; } }
So, the error is actually mine and works fine when using the right variable, $piece, as:
if ($piece =~ m/[ -~]/)
Sorry for the wasted space to post this question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex incorrectly matching newline
by ikegami (Patriarch) on Jun 23, 2006 at 19:21 UTC |