0

I am using Node.js to handle text with regex. I have the following strings

 <span class="ls8">,  <span class="ls8">respiration<span class="ls8">, and
 </span><span class="ls8">photosynthesis<span class="ls8">. At least </span>
 </span></span></span></div>

Here i am trying the following Regex, but did not get parent tags

 <span class="(.*?)">(.*?)<\/span>

Close span is not getting at end. But it catches first close span.

How to get parent span?

Any one assist me to handle?

Thanks in advance.

Vanarajan
  • 973
  • 1
  • 10
  • 35
  • 3
    use `.*` instead of `.*?`.. but avoid parsing `HTML` with regex – rock321987 Apr 08 '16 at 05:56
  • 4
    [Do not parse HTML with Regex!!!](http://stackoverflow.com/a/1732454/5743988) Use the DOM or an (HT|X)ML parser. – 4castle Apr 08 '16 at 05:57
  • 1
    You really should use something like the `cheerio` module to properly parse HTML instead of using regular expressions. – mscdex Apr 08 '16 at 06:04

0 Answers0