Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

MARV


In reply to Problem with regular expression by MARVion

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (2)
    As of 2014-09-22 23:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (208 votes), past polls