Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Regular Expression Help

Hi there,

I have this regular expression:  <\s*(div)\s*([^/>]*)(?:>(.*?)</\1>|/>)     which seems to match div tags which is nice, however i need it to also match span tags.

In fact, it would be handy if it worked the other way round, given the string "aboutContent" it could match all tags that contain the id "aboutContent"   ie;

<div id="aboutContent" class="maybe_a_class">some text here</div>
<span id="aboutContent">blah de blah</span>

once i have the complete string as above, would great if i could break it down into:

tag
id
class
content

eg:
tag = "div"
id = "aboutContent"
class = "maybe_a_class"
content = "blah de blah"

in c# for a gold star :)



0
Type25
Asked:
Type25
  • 2
1 Solution
 
ozoCommented:
<\s*(\w+)\s*id="(aboutContent)"\s*(?:class="([^"]*)")?\s*(?:>(.*?)</\1|/)>
0
 
Type25Author Commented:
You star!

0
 
Type25Author Commented:
Another question for you ozo,

Thanks
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now