Re: double substitution

2011-09-20 Thread Shawn H Corey
On 11-09-19 08:56 PM, Rajeev Prasad wrote: $string="alpha number='42'" $string=~s/.*\=// ; $string=~s/\'//g; to get 42 and not '42' can these two substitutions be combined? thank you. It depends on what you want to extract. To extract a string inside single quotes after an equal sign:

Re: double substitution

2011-09-19 Thread Rob Dixon
On 20/09/2011 02:17, Jim Gibson wrote: On 9/19/11 Mon Sep 19, 2011 5:56 PM, "Rajeev Prasad" scribbled: $string="alpha number='42'" $string=~s/.*\=// ; $string=~s/\'//g; to get 42 and not '42' can these two substitutions be combined? If you know what you want to extract, then use capturin

Re: double substitution

2011-09-19 Thread Jim Gibson
On 9/19/11 Mon Sep 19, 2011 5:56 PM, "Rajeev Prasad" scribbled: > $string="alpha number='42'" > $string=~s/.*\=// ; > $string=~s/\'//g; > > to get 42 and not '42' > > > can these two substitutions be combined? If you know what you want to extract, then use capturing: if( $string =~ /'(\d+)

Re: double substitution

2011-09-19 Thread Rob Dixon
On 20/09/2011 01:56, Rajeev Prasad wrote: $string="alpha number='42'" $string=~s/.*\=// ; $string=~s/\'//g; to get 42 and not '42' can these two substitutions be combined? Hi Rajeev Well they can be combined, and because it is far from obvious what your code is doing I think it should be r

double substitution

2011-09-19 Thread Rajeev Prasad
$string="alpha number='42'" $string=~s/.*\=// ; $string=~s/\'//g; to get 42 and not '42' can these two substitutions be combined? thank you. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/