Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi @ all,
I have a problem using a regular expression against some values. In most cases it works fine, but I have to skip some values, which isn't working. See, I have this array with different possible combinations:

$in[0]="TFS100"; $in[1]="TFS 100"; $in[2]="TFS-CR100"; $in[3]="TFS-CR 100"; $in[4]="TFS_100"; $in[5]="TFS ID 100"; $in[6]="TFS CR 100"; $in[7]="TFS ID100"; $in[8]="TFS-ID 100"; $in[9]="TFS ID:100"; $in[10]="TFS-ID: 100"; $in[11]="- TFS CR634: STRESS: H 17326,21600,"; $in[12]="CR0080588"; $in[13]="TFS0080588";
and i check with this regular expression:
$pattern = '[Tt]?[Ff]?[Ss]?[-_\s]?[Cc]?[Rr]?[\']?[Ii]?[Dd]?:?\s?(\d+)' +;
to also parse the numbers as I need them later in my code. This works fine for nearly all cases, but I have to "skip" or return false for the both last cases ([12] and [13]), if after some characters like "cr" or "tfs" the next value is a zero or double zero. Interesting is, that the number in [12] isn't recognized, but it is in [13]. I tried a lot of things but couldn't get it to work.
Maybe you can help me fixing my problem? This would be great!

Greetz from Germany
Yours sincerely


In reply to Problem with regular expression by MARVion

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (3)
    As of 2018-05-26 14:20 GMT
    Find Nodes?
      Voting Booth?