0

I have a javascript string like given below

function() {window.__WML_REDUX_INITIAL_STATE__ = {"uuid":null,"isMobile":false,"isBot":false,"isAdsEnabled":true};}

I have to get contents of __WML_REDUX_INITIAL_STAET__ = whose content is json data so that I could parse the json further.

I'm, using following regex pattern

wml_redux_initial_state = re.findall('__WML_REDUX_INITIAL_STATE__ = (.*?);\s*$', redux, re.M)

But this is not working.

1 Answer 1

1

I don't know how specific your regex needs to be, but your current one isn't working because of the } after the ;....this works:

re.search(r'__WML_REDUX_INITIAL_STATE__ = (.*?);}\s*$', redux, re.M)
Sign up to request clarification or add additional context in comments.

3 Comments

but this search includes __WML_REDUX_INITIAL_STATE__ string too. I only want content within it.
Thanks, I used your regex string in findall and it's working
in my re.search it returns a match object which contains what you're looking for in the first group. You could access it by match.group(1).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.