0

I get the content (source) of a webpage by using faraday in ruby. I want to extract a JS variable in the source code obtained with faraday. The JS variable is written like this :

argTab["labelExample"] = "theThingIWant";

I want to do this in ruby (framework rails).

1 Answer 1

1

How about this:

/\w+\[\"\w+\"\]\s\=\s\"(\w+)\"\;/.match(f)[1]

where f is your source string? It's important to note that this only escapes double quotes, but it could easily be improved to allow single or double quotes.

Sign up to request clarification or add additional context in comments.

Comments

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.