Venerable Monks,

I have written a small regular expression which I would like to be verified.Though the regular expression is working but I just wanted to check if there is a better way of picking up the values from the text string.Here it is...

Test String :

TAG001 LOCATION UPDATE 2009-05-08 14:30:50 TAG002 32300045985 11580;;543;MARIANO ESCOBEDO;OF 406 C 323 2 ACTIVE 2008-07-25 18:07:11 ERO007 2009-05-08 14:30:50 JTE015 1T61FJWLB97R2 MX TAG005 WENDA MARIANO ESCOBEDO 543 OF 406 COL RINCON DEL BOSQUE 11580 MEXICO DF DF MEXICO WNE051125MS8 10 Online PARTIAL 2 ZEXC 37 ES 0000000000094 TAG029 32300045984 1 TAG029

My Objective was is to pick two values from the above test string:

1.The value appearing after TAG002 i.e 32300045985 in $1

2.All of the strings appearing between TAG005 and the 'very first TAG029' in $2

The regular expression I wrote is:

.+TAG002 (\d+).+TAG005 (.+?)TAG029

Though the regular expression is working fine just wanted to check if there is a better way of doing it.Please comment if you think there was a better way to write the regular expression.

NOTE:The test string has special characters.

Thanks & Regards,

Gyatso

Update:

Thanks Utilitarian and Suaveant for your comments and suggestions.

Regards,

Gyatso


In reply to Please comment on my regular expression. by Gyatso

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.