dmsparts has asked for the wisdom of the Perl Monks concerning the following question:
HI,
i am trying to create a variable which contains a reference number matched from within a text string.
example,
textstring = Michael please look at E123456
where E123456 is a reference number i need to look at. i want this reference number to be added to a variable called $lookatref. The string is always in the same format, NAME please look at REF. The ref can be either one letter followed by 6 numbers or just 7 numbers
the code im using is
$lookatref = ""; $mystring2 = 'please look at '; if ($reqtext =~ m/$mystring2(.*?) /i) {$lookatref = $1;}
$reqtext is the text i want to match. this is read into the variable earlier in the script. i think it is something to do with the regex syntax, but i just cant figure out what it wrong.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex, query
by Ratazong (Monsignor) on Jan 24, 2013 at 15:55 UTC | |
by dmsparts (Sexton) on Jan 24, 2013 at 16:13 UTC | |
|
Re: Regex, query
by SuicideJunkie (Vicar) on Jan 24, 2013 at 15:57 UTC | |
|
Re: Regex, query
by kennethk (Abbot) on Jan 24, 2013 at 16:03 UTC |