I have a full page HTML scraped that have a lot of markup including HTML/CSS/JS code.
example below (stripped content)
<p>blah blah blah html</p>
<script type="text/javascript">window._userData ={"country_code": "PK", "language_code": "en",user:[{"user": {"username": "johndoe", "follows":12,"biography":"blah blah blah","feedback_score":99}}],"another_var":"another value"} </script>
<script> //multiple script tags can be here... </script>
<p>blah blah blah html</p>
Now I want to extract the object in window._userData
and then if possible convert that extracted string into PHP object/array.
I have tried a few regular expressions found on SO but couldn't get it working.
I have also tried the similar answer here Regular expression extract a JavaScript variable in PHP
Thanks