-2

This works to replace every other comma. What do I have to do to replace every third comma?

resultContent = resultContent.replace(/(,[^,]*),/g, '$1|');
4

1 回答 1

3
resultContent = resultContent.replace(/((?:,[^,]*){2}),/g, '$1|');
于 2013-04-16T21:07:38.807 回答