0

I wrote the following regular expression for the texts below:

"\<li\>\<span\>[\w\d\s\-\,\/\;]+\<\/span\>\<\/li\>"

HTML:

"<li><span>3-1/2-inch cutting edge and wedge-shaped spike</span></li>"
"<li><span>19-inch overall length; 24-ounce weight</span></li>"

But it doesn't work! What is the suitable pattern for that?

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
Mohammed Asaad
  • 138
  • 1
  • 6
  • `.*` — Really, just use an HTML parser to do it. A regex is not the right tool for parsing HTML. – Amal Murali Aug 07 '14 at 09:24
  • 2
    check this link http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – bansi Aug 07 '14 at 09:28

1 Answers1

1

Just use .*? to match everything until something else (lazy matching):

"<li><span>.*?<\/span><\/li>"

You can test it here.

enrico.bacis
  • 30,497
  • 10
  • 86
  • 115