Regular expression for removing an HTML attribute

Started by
0 comments, last by fastcall22 14 years, 6 months ago
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.

Beginner in Game Development?  Read here. And read here.

 

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.

<a href=">

[Edited by - _fastcall on October 29, 2009 4:34:16 PM]

This topic is closed to new replies.

Advertisement