MARVion has asked for the wisdom of the Perl Monks concerning the following question:
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:
and i check with this regular expression:$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";
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.$pattern = '[Tt]?[Ff]?[Ss]?[-_\s]?[Cc]?[Rr]?[\']?[Ii]?[Dd]?:?\s?(\d+)' +;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with regular expression
by Utilitarian (Vicar) on Feb 12, 2013 at 16:01 UTC | |
by AnomalousMonk (Archbishop) on Feb 12, 2013 at 17:18 UTC | |
|
Re: Problem with regular expression
by AnomalousMonk (Archbishop) on Feb 12, 2013 at 17:03 UTC | |
|
Re: Problem with regular expression
by choroba (Cardinal) on Feb 12, 2013 at 15:12 UTC | |
|
Re: Problem with regular expression
by MARVion (Novice) on Feb 13, 2013 at 09:38 UTC | |
by Utilitarian (Vicar) on Feb 13, 2013 at 13:24 UTC | |
|
Re: Problem with regular expression
by locked_user sundialsvc4 (Abbot) on Feb 12, 2013 at 19:25 UTC | |
|
Re: Problem with regular expression
by MARVion (Novice) on Feb 13, 2013 at 09:20 UTC | |
|
Re: Problem with regular expression (sub)
by Anonymous Monk on Feb 12, 2013 at 14:48 UTC |