I want to change the third comma in this string using regex in notepad
145, 45, 67, 688
With a ":" Like this :
145, 45, 67: 688
I tried this
(?:,)(,)*
I think I am missing something
CodePudding user response:
You can use this regular expression in the dialog window:
Find what: ^(([^,]*,){2}[^,]*),
Replace with: \1:
The first ^
matches at the start of the line. The expression ([^,]*,){2}
matches everything up to a comma two times. The expression [^,]*
then matches everything up to, but excluding, the third comma. The first so called capture group is referred to by \1
. In this case it refers to what's inside the outermost parentheses.
CodePudding user response:
If the third comma is always the last, you can check for the end of the string/line with $
:
,(?=[^,]*$)