php - Regex that finds JSON string inside another string -


i extract json string within string.

currently getting full string using file_get_contents , running following pattern on string: https://regex101.com/r/5jauco/1 pretty gives multiple matches.

i extract json string saved in window._shareddata haven't been able achieve that. have idea how that?

why not include _shareddata in regex like? _shareddata\s*=\s*\{.+\}

  • or lookbehind: (?<=_shareddata\s=)\s*\{.+\}

  • or take json capturing group: _shareddata\s*=\s*(\{.+\})

one concern lookbehind if add additional whitespace character between _shareddata , = won't match.

this works since there no linebreaks in json.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -