I have this fiddle
I'm trying to get the html inside the <app>
tag, but can't seem to get it working. How can I fix it? The regex I am using is .match(/<app.*>(.*?)<\/app>/)[1];
Asked
Active
Viewed 36 times
-3

williamsandonz
- 15,864
- 23
- 100
- 186
-
1why don't you using `.find('app')` so you can search in the parsed form, instead in string content – Koushik Chatterjee Dec 15 '17 at 10:31
-
Or `document.getElementsByTagName("app")[0].innerHTML`? – slhck Dec 15 '17 at 10:33
-
Can't I'm doing this on server side. – williamsandonz Dec 15 '17 at 10:39
-
1Next time asking a question, please add more details and show what you've already tried or ruled out. – slhck Dec 15 '17 at 10:50
1 Answers
1
That's because .
matches everything except for newlines, but you want to match everything. Use [\s\S]
instead. Check it here: https://jsfiddle.net/vumcgger/
Also, never parse html with regex (unless you really need to): RegEx match open tags except XHTML self-contained tags

Ethan
- 4,295
- 4
- 25
- 44
-
1Thanks, yeah I'm doing it inside node, having to scrape some content and extract a few things. Thanks that works great. – williamsandonz Dec 15 '17 at 10:39