Re: Reg ex : tabs/spaces

2004-10-18 Thread John W. Krahn
Ajey Kulkarni wrote: Thanks a ton Gunnar, How about the intermediate blanks? Is there a way to recursively take all blanks/tabs that occur?? word=Detail Design Activity Included# I would like to remove the blanks here.. Recursion is not required. $word =~ tr/ \t//d; John -- use Perl; program fulfil

Re: Reg ex : tabs/spaces

2004-10-17 Thread Gunnar Hjalmarsson
Ajey Kulkarni wrote: #snippet to replace all the ,, with ,NEW, my($word) = " Detail Design Activity Included ,-1,0 ,hello,ajey "; $word =~ s/\s+//g; $word =~ s/,,/,NEW,/gc; The /c modifier is redundant, which Perl would have told you if warnings had been enabled. :( Ple

Re: Reg ex : tabs/spaces

2004-10-17 Thread Ajey Kulkarni
One more extension to this qn. #snippet to replace all the ,, with ,NEW, my($word) = " Detail Design Activity Included ,-1,0 ,hello,ajey "; $word =~ s/\s+//g; $word =~ s/,,/,NEW,/gc; printf "word=$word#\n"; after removing the blanks ,if there are any ",," i would like

Re: Reg ex : tabs/spaces

2004-10-17 Thread Gunnar Hjalmarsson
Ajey Kulkarni wrote: Gunnar Hjalmarsson wrote: Ajey Kulkarni wrote: I would like to remove all the spaces & tabs from a variable. No, you wouldn't. You would like to remove possible whitespace from the beginning and end of a string. my($word) = " Detail Design Activity Included "; $word =

Re: Reg ex : tabs/spaces

2004-10-17 Thread Ajey Kulkarni
Thanks a ton Gunnar, How about the intermediate blanks? Is there a way to recursively take all blanks/tabs that occur?? word=Detail Design Activity Included# I would like to remove the blanks here.. TIA -Ajey On Sun, 17 Oct 2004, Gunnar Hjalmarsson wrote: > Ajey Kulkarni wrote: > > I would lik

Re: Reg ex : tabs/spaces

2004-10-17 Thread Gunnar Hjalmarsson
Ajey Kulkarni wrote: I would like to remove all the spaces & tabs from a variable. No, you wouldn't. You would like to remove possible whitespace from the beginning and end of a string. my($word) = " Detail Design Activity Included "; $word =~ s/^\s*(\D*)\s*$/$1/; It's best done using t