Public Group

# 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.

## 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">

##### 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*\>

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.

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 10
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633405
• Total Posts
3011680
• ### Who's Online (See full list)

There are no registered users currently online

×