Yet another way to do it:
$s = join(",", map {$_ ne '' ? $_ : '0'} split /,/,$s,-1);
Update: Added '-1' to split to ensure we don't lose trailing commas, as hdb mentions. (Also corrected typo $t-->$s.)
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Regex to replace consecutive tokens
by roboticus
in thread Regex to replace consecutive tokens
by {}think
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |