Link to home
Start Free TrialLog in
Avatar of rw263
rw263

asked on

RegEx

I have a string containing: $to = "$a,$b,$c,$d,$e".
$a through $e contain multiple email addresses separated by commas, no space in te $to line.
If $a is present then the initial value of the $to would be: $to = ",email1@place,com,....."
I tried:
 $to =~ s/^,//;
 $to =~ s/,,/,/;

Which seems to work however, if the string is $to = ",b,c,,,", it will return $to = "b,c,," not $to = "b,c"

Any ideas?

I even tried: $to =~ s/,+/,/;

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(but be aware that "," is a valid character in an email name)
Avatar of rw263
rw263

ASKER

wonder why mine didn't work, but this does. thanks ozo!