Regular Expression Help

Posted on 2004-11-16
Last Modified: 2010-04-17
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 = "div"
id = "aboutContent"
class = "maybe_a_class"
content = "blah de blah"

in c# for a gold star :)

Question by:Type25
    LVL 84

    Accepted Solution

    LVL 9

    Author Comment

    You star!

    LVL 9

    Author Comment

    Another question for you ozo,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Suggested Solutions

    Title # Comments Views Activity
    Help with my python script 6 135
    zeroMAx challenge 20 66
    matchUp  challenge 9 48
    triangle challenge 4 34
    Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now