stallion has asked for the wisdom of the Perl Monks concerning the following question:
Hi i have written a regex to match some tags ..the issue is when i try to match "-"(HYPHEN) in the tag , "_"(UNDERSCORE) is also getting matched...the regex is written below:-
$Prefix='DOC_'; if ($line =~ /$Prefix[a-zA-Z]*[0-9]*-*[0-9a-z]{3}/)
the tags are
DOC_001_123
DOC_002_214
DOC_001-548
DOC_001-987
I want the last two tags with the - but im getting every tags... where is the issue in the above regex..thanks....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex MATCH
by kcott (Archbishop) on Sep 14, 2012 at 08:37 UTC | |
|
Re: Regex MATCH
by 2teez (Vicar) on Sep 14, 2012 at 08:44 UTC | |
|
Re: Regex MATCH
by Utilitarian (Vicar) on Sep 14, 2012 at 08:14 UTC | |
by bart (Canon) on Sep 14, 2012 at 10:45 UTC | |
|
Re: Regex MATCH
by BillKSmith (Monsignor) on Sep 14, 2012 at 14:31 UTC |