in reply to Regex to add space after punctuation sign
The best I can come up with is
#! /usr/bin/perl use strict; while( <DATA> ) { s/(?<!\d), *|, *(?=\D)/, /g; print; } __DATA__ 1,2,a,b 1,a,2,b 1,a,b,2 a,1,2,b __produces__ 1,2, a, b 1, a, 2, b 1, a, b, 2 a, 1,2, b
But the use of alternation strikes me a bit as cheating. There is no doubt ABWTDI, but I can't see it for the moment.
|
|---|