Thanks so much for the response, Marcus.
Now I know why I was struggling. Sometimes I need human interaction to
understand concepts besides just reading a book.
More reply below -
On 10 Sep 2001 13:51:23 +0200, HOLLAND-MORITZ,MARCUS (A-hsgGermany,ex1)
wrote:
>
> Yes, there's a better way. Catch the digits with parentheses inside
> the regex and evaluate the match in list context to get the result:
>
> -----------------------------------------------------------
> $job{Ra} = 'Ra: 45k';
>
> if( ($x) = $job{Ra} =~ /(\d\d)/ ) {
> print "the number is: $x\n";
> }
> else {
> print "no number... :-(\n";
> }
> -----------------------------------------------------------
I think I understand what you're doing here -
The 'if' line captures the REGEXP & stores it in $x, then evaluates it
using the 'if' condition.
In this example is it important to have the parenthesis (brackets)
around the '\d\d'? Also why is "($x)" in brackets?
I assume that /(\d\d)/ is finding one double-digit number in the string.
What if I am looking for 2 numbers in the string? The REGEXP will find
the first number, right? How do I go about finding the next number if
any?
--
regs
rupert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]