J
justme
hi
in my script i will process from a database and assign a value to a
variable $var1
The value assigned to $var1 is a number. eg 1, 2 or 3. But it is in
"string" format. There will be spaces in front as well as behind it.
eg
$var1 = xxxxxxx2xxx
or
$var1 = xxx3xxxxxxxxxxx
where x = spaces.
I want to remove these spaces and just get the number. so i tried to
use
$var1 =~ s/(.*)(\d)(.*)/\2/ ;
Then when i print the length of $var1, it says length is 2. Is there
anything wrong with my regexp?
thanks for help
in my script i will process from a database and assign a value to a
variable $var1
The value assigned to $var1 is a number. eg 1, 2 or 3. But it is in
"string" format. There will be spaces in front as well as behind it.
eg
$var1 = xxxxxxx2xxx
or
$var1 = xxx3xxxxxxxxxxx
where x = spaces.
I want to remove these spaces and just get the number. so i tried to
use
$var1 =~ s/(.*)(\d)(.*)/\2/ ;
Then when i print the length of $var1, it says length is 2. Is there
anything wrong with my regexp?
thanks for help