Jump to content
  • Advertisement
Sign in to follow this  

Regular expression for removing an HTML attribute

This topic is 3308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I'm using the Find and Replace Tools for VS 2008. I'm trying to write a regular expression that makes this: <td id="blah" runat="server"> into this: <td runat="server"> What I came up with is this:
Find: <td id='{"...."}' runat="server">
Replace with: <td runat="server">
But obviously that's not working. I've googled, but to no avail. So. Please help.

Share this post

Link to post
Share on other sites
Try this:
Find: \<td id="[^"]+" runat="server"\>
Or this:
Find: \<td:Wh+id:Wh*=:Wh*("|')[^"']+("|'):Wh+runat:Wh*=:Wh*("|')server("|'):Wh*\>

Replace With: <td runat="server">

Curly braces denote matching groups to use in the replace field, \0 being the whole entire match, \1 being the match in the first set of curly braces, and etc. Angle brackets denote beginning and ending of a string. Period matches any one character, :Wh matches any whitespace and the rest of them can be found on this article.


  • Sign in to follow this  

    • Advertisement

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!