Re: Multiline regex not matching



Shmuel Metz <spamtrap@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
In <slrnjie0if.dku.hjp-usenet2@xxxxxxxxxxxxxxx>, on 01/30/2012
at 09:49 PM, "Peter J. Holzer" <hjp-usenet2@xxxxxx> said:

Since the "EOF" is inserted by one space I guess that you indented
the whole script by one space before posting.

Yes.

If this is true, there is no
space before "by lincoln-at-leros.patriot.net ..."

If this is true, there is no
space before "by lincoln-at-leros.patriot.net ..."

Ouch! Another case of seeing what I expect instead of what's there.

It does match if leading whitespace is inserted, so it seems that
your regexp is correct, but your data isn't.

Yes, I should have indented the continuation line..


As we have seen, it is critically important for us to see BOTH the
string to be matched against AND the pattern (regex) that is to be
matched if we hope to figure out why it is not behaving as expected.


I'm making progress, but still have some matches that aren't doing
what I expect.

With $testheader= from localhost (localhost [127.0.0.1])
by lincoln-at-leros.patriot.net (Postfix) with ESMTP id 12BBE55E73
for <marianne@xxxxxxxxxxx>; Fri, 27 Jan 2012 09:23:59 -0500 (EST):


Nobody knows what string is in $testheader (because it is not loaded
up in Real Perl Code) so we cannot help with matching it...


You should make an unambigous representation of your string:

$testheader = "from localhost (localhost [127.0.0.1])\n"
. "by lincoln-at-leros.patriot.net (Postfix) "
. "with ESMTP id 12BBE55E73\n"
. "for <marianne@xxxxxxxxxxx>; Fri, 27 Jan 2012 "
. 09:23:59 -0500 (EST):\n";

--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
.



Relevant Pages

  • Re: Regexp, ***= and subexpressions
    ... specified that the user's input be treated as a literal string rather than ... -exact] in cases where regexp isn't required:P ... Seems to be that regexp can't match word boundaries at "non-word" ... But now Earth has rotated and I can get back to sleep. ...
    (comp.lang.tcl)
  • Re: Regexp: Case-insensitive matching | N factorial
    ... a regexp component that matches a string of letters, ... Will match the string 'cat' anywhere it appears regardless of case. ... Javascript regular expressions have an alternative operator '|' (kind ...
    (comp.lang.javascript)
  • Re: Regular expression 0 - number range.
    ... involves creating a RegExp instance with a number of nested alternations, ... and matching that against a string value. ... accept and interpret properly according to ES5, section 15.9.3.2), and then ... one can just prepend 1 to YYYY. ...
    (comp.lang.javascript)
  • Re: How to get the "longest possible" match with Pythons RE module?
    ... Under most "NFA" implementation, such a regexp is ... searching a very long string that happens not to contain any matches. ... under many implementations it's very easy to end ... double-quote character at each end, and backslash escapes, ...
    (comp.lang.python)
  • Re: Regular Expression confusion
    ... > Christie Taylor wrote: ... That regexp has ... the end of the string will match, regardless of what is at the beginning ... you don't intend a capture, use instead, which is identical ...
    (comp.lang.perl.misc)