• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

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!
0
rw263
Asked:
rw263
  • 2
1 Solution
 
ozoCommented:
$to =~ s/^,+//;
$to =~ s/,+$//;
$to =~ s/,+/,/g;
0
 
ozoCommented:
(but be aware that "," is a valid character in an email name)
0
 
rw263Author Commented:
wonder why mine didn't work, but this does. thanks ozo!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now