Kristofer,
you might want to check out the man page's perlrequick and perlre- I found 
them pretty useful when I was first learning regex (the man page perlretut 
isn't bad either).

Either way, try this;
my $string = '(608)-555-1234';
$string =~ /\((\d+)\)-(\d+)-(\d+)/;
this results in $1=608, $2=555, $3=1234;

For extracting a match in a regex, you just enclose it in parenthesises... 
perl dumps it then to var's $[1-9].
One thing to consider is if a match isn't found- unless I'm mistaken, perl 
won't do anything to the $[1-9] match variables leaving the variables with 
there previous values.  Something to watch/test for...
~Brian


On Wednesday 26 June 2002 11:21, Kristofer Hoch wrote:
> Hi all,
>   Please forgive the simple nature of this question. I have never really
> used regular expression extensivly.
>
>   Here goes. I am trying to extract a number from in between two
> parenthesis. I want the first value I find (from right to left) in a
> string. These numbers could be phone number area codes, or comments.
>
> Could someone please help, so that I can shamelessly use it all over the
> place?
>
> Thank you
> Kristofer.
>
>
>
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to