I am looking for a way to remove the first occurrence of a comma in a string, for example
\"some text1, some tex2, some text3\"
should retu
A simple one liner will do it:
text = text.replace(/^(?=(?:[^,]*,){2})([^,]*),/, '$1');
Here is how it works:
regex = re.compile(r"""
^ # Anchor to start of line|string.
(?= # Look ahead to make sure
(?:[^,]*,){2} # There are at least 2 commas.
) # End lookahead assertion.
([^,]*) # $1: Zero or more non-commas.
, # First comma is to be stripped.
""", re.VERBOSE)