[PHP] str_replace around a character??

2011-07-13 Thread Karl DeSaulniers
Hello All, I am needing some assistance. I am trying to add some Cc and Bcc to a mail script I have. On the form I have instructions for each to be separated by a comma + a space. In an all perfect world each user would do this perfectly. ...but since were working with something different,

Re: [PHP] str_replace around a character??

2011-07-13 Thread Jay Ess
On 2011-07-13 09:54, Karl DeSaulniers wrote: $cc = ema...@domain.com ,ema...@doamin.com,ema...@domain.com , ema...@domain.com, $cc = trim($cc,,); $result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] str_replace around a character??

2011-07-13 Thread Vitalii Demianets
On Wednesday 13 July 2011 11:09:45 Jay Ess wrote: On 2011-07-13 09:54, Karl DeSaulniers wrote: $cc = ema...@domain.com ,ema...@doamin.com,ema...@domain.com , ema...@domain.com, $cc = trim($cc,,); $result = preg_replace('/(\s?)(,)(\s?)/i', ',', $cc); The solution is broken because of: 1)

Re: [PHP] str_replace around a character??

2011-07-13 Thread Jay Ess
On 2011-07-13 10:36, Vitalii Demianets wrote: On Wednesday 13 July 2011 11:09:45 Jay Ess wrote: On 2011-07-13 09:54, Karl DeSaulniers wrote: $cc = ema...@domain.com ,ema...@doamin.com,ema...@domain.com , ema...@domain.com, $cc = trim($cc,,); $result = preg_replace('/(\s?)(,)(\s?)/i', ',',

Re: [PHP] str_replace around a character??

2011-07-13 Thread Shiplu Mokaddim
If you are looking for a one liner reg ex, it may take some time. This may lead wasting your development time. Better you do the following, 1. replace the string with tokens in address. 2. Split using comma. 3. Apply common email regex. 4. Replace tokens with actual strings. 5. Rebuild/join the