jeanluca has asked for the wisdom of the Perl Monks concerning the following question:
I need the text + the spaces in between but not the spaces at the beginning or end!!$str = " abc defgh ij klmnop " ; # case 1 $str = " abc defgh ij klmnop qrst uvwxyz" ; # case 2 $str = "abc defgh ij" ; #case 3
It only fails in case 1, it leaves a space at the end....($str) = ($str =~ /^\s([\w+\s{0,}]{1,})\s{0,}$/) ; #case 2/3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regexp problem
by Limbic~Region (Chancellor) on Dec 08, 2005 at 13:38 UTC | |
|
Re: regexp problem
by secret (Beadle) on Dec 08, 2005 at 13:36 UTC | |
|
Re: regexp problem
by ysth (Canon) on Dec 08, 2005 at 13:39 UTC | |
|
Re: regexp problem
by SamCG (Hermit) on Dec 08, 2005 at 15:29 UTC | |
|
Re: regexp problem
by Perl Mouse (Chaplain) on Dec 08, 2005 at 14:12 UTC |