Hello all, Can someone tell me why the following regex does not work? What I want is just the date information "1st day of November 2005". Thanks a bunch!
my $aa = "Accepted and agreed to by Jerry Smith as of the 1st day of N +ovember 2005."; if ( $aa =~ m{ (?:as of)* (?:\s|\n)* #for any possible space or line end (?:this|the)* (?:\s|\n)* #for any possible space or line end ( (?:[1-31]) #day, 1 to 31 (?:st|nd|rd|th) #for all the cases like 1st, 2nd, 3rd, 25th (?:\s|\n)* #for any possible space or line end (?:day of)* (?:\s|\n)* #for any possible space or line end (?:January|February|March|April|May|June|July| August|September|October|November|December) (?:\s|\n)* #for any possible space or line end (?:\,|\s)* #for any possible space or comma end (?:\s|\n)* #for any possible space or line end ([1,2]\d{2,3}) #year ) (?:\,|\.|\s)* (?:[ ]{2}|\n|\z)* #Two spaces, newline, or string end }ixmsg) { print $1; }
It works now. I am really grateful to davorg, Fletch, johngg, aggianni,anno, and shmem for all your helpful comments and suggestions. I just get to know PERL for about two weeks and it is great that I find this forum and so many nice and helpful experts here.

In reply to Regex question by coltman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.