0

I want to get string from between \" using regular expression.

Input : "gram:\"who is $t34he\""

Expected Ouput : who is $t34he

I tried /\\"(.*?)\\"/g this and got \"who is $t34he\" but I don't need \" into the output string. Any solution.

Tried on http://www.regexr.com/

iNikkz
  • 3,729
  • 5
  • 29
  • 59

2 Answers2

0

You can use looakaheads/behinds if supported

(?<=\\").*?(?=\\")

DEMO

Anyway, if not supported, just use \\"(.*?)\\" and take Group 1.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95
0

My first attempt at an answer (please bear with me if if there are slight errors!):

Using your site I got it to work with

[\w\s]*\$[\w]*

(where \w matches alphanumerical characters and \s whitespace)

That matches any dollar sign with alphanumerical+whitespace characters before it and alphanumerical chars after... so it starts and stops the match neatly between the quotes and backslashes. Am happy to make it more general if given more info on what expected inputs are. I hope the answer is constructive!

Sonke Hee
  • 151
  • 1
  • 9