I have a javascript variable, for example:
var s = "<result>Success</result><name>George</name>";
How can I get with javascript regex the result ‘Success’ and name ‘George’?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The regex you are looking for is
However, as a general rule of thumb – don’t ever use regex to parse HTML. The reason is that the browser already has XML parsers built-in, so why use ugly regex to do something the browser already does?
Parsing XML:
http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery
Parsing HTML using the DOM: How to parse HTML from JavaScript in Firefox?