-2

I have the following situation:

  • 3" a
  • 3":a
  • 3",a
  • 3"a
  • 3"2
  • 3"A

I need to find a replace a double quote with space every time the double quote is not following by : or ,.

So, for my case the expected results will be:

  • 3 a
  • 3":a
  • 3",a
  • 3 a
  • 3 2
  • 3 A

Any idea how write this logic using regex?

Regards,

Nati
  • 15
  • 1
  • 6

1 Answers1

0

You can use a negative lookahead A(?!B) for that. It matches an expression A that is not followed by expression B. The replacement of the matches with spaces will depend on the used language.

"(?![:,])

Applied to your examples: https://regex101.com/r/UiPlaC/2

If you want to handle the case 3" a without having multiple spaces, just include one (or even more?) optional spaces in the match.

"(?![:,])\ ?

See here for more information: