icoder has asked for the wisdom of the Perl Monks concerning the following question:
I tried to pull out a signed /or unsgined number from string using regexp in perl.
$str = "This string has a number +15 init "; regex : m/.*([\+|-](\d+)).*$/ #which works well for above said +string
but consider this case
$str = "This string has a number15 init"; #i need to fix the above regex to work for avove string as well
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pull out num from str
by aaron_baugher (Curate) on Apr 23, 2012 at 07:50 UTC | |
by jwkrahn (Abbot) on Apr 23, 2012 at 08:45 UTC | |
by icoder (Novice) on Apr 23, 2012 at 09:14 UTC | |
by icoder (Novice) on Apr 23, 2012 at 11:55 UTC | |
by aaron_baugher (Curate) on Apr 23, 2012 at 17:01 UTC | |
|
Re: pull out num from str
by Anonymous Monk on Apr 23, 2012 at 07:10 UTC | |
by icoder (Novice) on Apr 23, 2012 at 07:16 UTC | |
by rovf (Priest) on Apr 23, 2012 at 08:42 UTC | |
|
Re: pull out num from str
by JavaFan (Canon) on Apr 23, 2012 at 11:20 UTC | |
by icoder (Novice) on Apr 23, 2012 at 14:03 UTC | |
by JavaFan (Canon) on Apr 23, 2012 at 14:16 UTC | |
by icoder (Novice) on Apr 24, 2012 at 05:33 UTC | |
|
Re: pull out num from str
by 2teez (Vicar) on Apr 23, 2012 at 09:12 UTC |