M
mike
hi folks
i have to strip a line of empty spaces/tabs before and after a comma
eg word1, word2 ,word3,word4<tab>,word5
i have to make it become word1,word2,word3,word4,word5
so far i have tried
$line =~ s/^\s+//; #get rid of spaces in the beginining of the line
$line =~ s/^\t+//; #get rid of tabs in the beginning of the line
$line =~ s/\s+,/,/g ; #get rid of spaces before a comma
$line =~ s/,\s+/,/g; #get rid of spaces after a comma
$line =~ s/\t+,/,/g; #get rid of tables before comma
$line =~ s/,\t+/,/g; #get rid of tabs after comma
i may have the line also containing eg
word1, word2 <2 tabs> ,word3,word4<1 tab><space><space>,word5
or other combinations of spaces/tabs .
Is there a better way to do the regexp? I just need the output to be
word1,word2,word3,word4,word5
thanks for any help
i have to strip a line of empty spaces/tabs before and after a comma
eg word1, word2 ,word3,word4<tab>,word5
i have to make it become word1,word2,word3,word4,word5
so far i have tried
$line =~ s/^\s+//; #get rid of spaces in the beginining of the line
$line =~ s/^\t+//; #get rid of tabs in the beginning of the line
$line =~ s/\s+,/,/g ; #get rid of spaces before a comma
$line =~ s/,\s+/,/g; #get rid of spaces after a comma
$line =~ s/\t+,/,/g; #get rid of tables before comma
$line =~ s/,\t+/,/g; #get rid of tabs after comma
i may have the line also containing eg
word1, word2 <2 tabs> ,word3,word4<1 tab><space><space>,word5
or other combinations of spaces/tabs .
Is there a better way to do the regexp? I just need the output to be
word1,word2,word3,word4,word5
thanks for any help