1

I have this field in my JSON data:

"pinyin": "bei1 'ai1",

I just want to select any single quote ' like the one before ai1;

I tried this

(?<="pinyin": "\w*)\'+(?!")

but it didn't work

João Pedro
  • 794
  • 2
  • 12
  • 28

1 Answers1

1

You can use

(?<="pinyin": "[\w\s]*)'(?!")

See this regex demo. Details:

  • (?<="pinyin": "[\w\s]*) - a positive lookbehind that matches a location that is immediately preceded with "pinyin": " and then any zero or more word or whitespace chars
  • ' - a single quotation mark
  • (?!") - a negative lookahead that fails the match of there is a " char immediately to the right of the current location.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563