Regex find a comma between two strings

I'm trying to remove commas from a certain place within a text file. The input looks like this:

Y=6","~2807-1 Q12m. Plate(s), screw(s), rod(s) or pin(s) in any bone - NO"

I only want to remove the commas between the "Y=6","" and the ending double quote. If I use

(?<=Y=\d",").*(?=")

I can isolate the part between those but can't for the life of me figure out how to just get the commas.

1 Answer

  • Find: (?:Y=\d","|\G)[^,"]*\K,
  • Replace: NOTHING

Demo

Explanation:

(?: # start non capture group Y=\d # literally Y= followed by 1 digit. You may want to use \d+ for 1 or more digits "," # literally "," | # OR \G # restart form last match position
) # end group
[^,"]* # 0 or more any character that is not comma or double quote
\K # forget all we have seen until this position
, # a comma

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like