jeudi 16 mars 2017

Replace until all occurences are removed

I have the following strings:

",||||||||||||||"
",|||||a|||||,|"

I would like to achieve that all occurrences of ",|" are replaced with ",,"

The output should be the following:

",,,,,,,,,,,,,,,"
",,,,,,a|||||,,"

When I run .gsub(',|', ',,') on the strings I get not the desired output.

",,|||||||||||||"
",,||||a|||||,,"

That's because it does not run gsub several times. Is there a similar method that runs recursively.

Aucun commentaire:

Enregistrer un commentaire