Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I am trying to identify a pattern like this in regular expression:
And replace with same - last 4 attributes.
<polypolygon name="PolyPolygon35" height="13" width="23" left="346" top="126" visible="true" wallpaper="false" isreferenceobject="false" backstyle="solid" backcolor="#3F3F3F" forecolor="black" linestyle="solid" linewidth="1" patternstyle="none" patterncolor="black" endcolor="white" gradientstop="50" gradientdirection="gradientDirectionHorizontal" gradientshadingstyle="gradientHorizontalFromRight">


All values in quotes are not important only this
<polypolygon as a literal matters along with the ending >


I really need an exact match on this pattern with its attributes (not the attribute values in quotes - they are unimportant) , so I can replace all the last 4 attributes with nothing.

If any one can get me started in the right direction I can work it out - I tried
<polypolygon

with a numeric count - but that tends to get problems not identifying correctly so my reg-ex is probably bad.
Thank you all for your time and help.
Posted
Updated 26-Jun-14 6:27am
v2
Comments
PIEBALDconsult 26-Jun-14 12:51pm    
http://blog.codinghorror.com/parsing-html-the-cthulhu-way/
OriginalGriff 26-Jun-14 14:02pm    
That should have been the answer, really...:laugh:

1 solution

PIEBALDConsult is right: a regex is a very, very poor way to parse HTML / XML - it really is a recipe for problems, bugs, and frustration - particularly when you need a minor change in three months time, and you have forgotten how that unreadable Regex works...

Have a look at the HTML Agility Pack[^] - it'll probably do most of what you want a lot simpler and quicker.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900