-2

I have this long string, "The words Text and dots represent whole bunch of html code"

Input:

TextTextTextTextTextTextTextText....."signed_request" value="Random Value" />TextTextTextTextTextTextTextTextTextText.....

How do i match all the text before and after the string "signed_request" value="Random Value" but not the string itself, considering the random value between the quotation marks, so it would output

Output: TextTextTextTextTextTextTextText...../>TextTextTextTextTextTextTextTextTextText.....

Rafat Mahmoud
  • 130
  • 3
  • 16
  • 2
    Does the string change or stay consistent? If consistent, can you not just do a simple replace of that substring? On another note, if this is **HTML**, use a parser for this task. – hwnd Aug 06 '15 at 19:31
  • It's a facebook html response when launching an app. Some values do change, just like the signed request. – Rafat Mahmoud Aug 06 '15 at 19:34
  • I'm using a web debugging proxy software called Charles and it has an html parser. – Rafat Mahmoud Aug 06 '15 at 19:38
  • I'm trying to replace all the code before and after this "signed_request" value="Random Value" with blank which will leave me with the signed request only – Rafat Mahmoud Aug 06 '15 at 19:42
  • http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags?rq=1 –  Oct 06 '16 at 16:13

1 Answers1

3

Try this Regex

/\s*\/>\w+|\w+(?="\S)/g

Check Here

Thanks @dustmouse.

Arunesh Singh
  • 3,489
  • 18
  • 26