sondeen@isi.edu (Jeff Sondeen) (03/05/91)
The following works without the caret (^) specifying beginning of line; with the caret, it doesn't match the input (which starts in column 1): program: perl -ne 'if (/^\w:/) { print; }' on input: nope: gives result: <nothing> expected result: nope: hypothesis: the caret(^) specifying beginning of line is messing up the regular expression matching version: This is perl, version 3.0 ... Patch level: 44 -- /jeff sondeen@isi.edu "engineers were discouraged from bringing problems to the attention of their supervisors" -- John Magnus, final report, Hubble Space Telescope investigation
tchrist@convex.COM (Tom Christiansen) (03/05/91)
From the keyboard of sondeen@venera.isi.edu (Jeff Sondeen): : :The following works without the caret (^) specifying beginning of line; with :the caret, it doesn't match the input (which starts in column 1): : :program: perl -ne 'if (/^\w:/) { print; }' :on input: nope: :gives result: <nothing> :expected result: nope: :hypothesis: the caret(^) specifying beginning of line is messing up the : regular expression matching :version: This is perl, version 3.0 ... Patch level: 44 Not sure how that's a bug: /\w/ doesn't mean /\w+/, so /^\w/ can be expected to fail on "nope:". --tom
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (03/05/91)
In article <16981@venera.isi.edu> sondeen@venera.isi.edu (Jeff Sondeen) writes:
:
: The following works without the caret (^) specifying beginning of line; with
: the caret, it doesn't match the input (which starts in column 1):
:
: program: perl -ne 'if (/^\w:/) { print; }'
: on input: nope:
: gives result: <nothing>
: expected result: nope:
: hypothesis: the caret(^) specifying beginning of line is messing up the
: regular expression matching
Alternate hypothesis:
\w matches a word character, not a word. Test by using \w+ instead.
Larry