I honestly see no reason to use Regular Expressions in something simple.
In PHP utilize explode
and join
$str = '32132132132 32132132132 321321321323 32132132132132';
$exp = explode(' ', $str);
echo "'" . join("';'", $exp) . "'";
See working in repl it.
In Python utilize split
and join
str = '32132132132 32132132132 321321321323 32132132132132';
exp = str.split();
print("'" + "';'".join(exp) + "'")
See working in repl it.
In Java utilize split
and join
String link = "32132132132 32132132132 321321321323 32132132132132";
String[] partes = link.split(" ");
System.out.println("'" + String.join("';'", partes) + "'");
See working in repl it.
In Javascript utilize split
and join
let str = '32132132132 32132132132 321321321323 32132132132132';
let res = "'" + str.split(' ').join("';'") + "'";
console.log(res)
Language is missing, Regexs (Regular Expressions) work differently depending on the Language
– Sveen
Possible duplicate of Regular expression to validate a field that accepts CPF or CNPJ
– user28595
I would do something like: demo, that would work in some of the simplest text editors... Your question would be more to replace in a list that has space as separator, to comma as separator and to put apostrophe delimiting each element. And not treat CNPJ...
– danieltakeshi