• Advertisement
Sign in to follow this  

Regular expression for removing an HTML attribute

This topic is 3037 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
Advertisement
Try this:
Find: \<td id="[^"]+" runat="server"\>
Or this:
Find: \<td:Wh+id:Wh*=:Wh*("|')[^"']+("|'):Wh+runat:Wh*=:Wh*("|')server("|'):Wh*\>

With:
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.

HTH.

  • Sign in to follow this  

    • Advertisement