65.9K
CodeProject is changing. Read more.
Home

.Net - Use The Framework

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.33/5 (9 votes)

Apr 6, 2010

CPOL
viewsIcon

8752

The following is far easier to understand and use than the Outlaw's tip (IMHO).text = Regex.Replace(text, "screen_fadetimeout=\"[^\"\']+\"", "screen_fatetimeout="99");It has the following advantages:1. It is one line of code2. It is easier to read3. It is faster (note: XmlElement...

The following is far easier to understand and use than the Outlaw's tip (IMHO).
text = Regex.Replace(text, "screen_fadetimeout=\"[^\"\']+\"", "screen_fatetimeout="99");
It has the following advantages: 1. It is one line of code 2. It is easier to read 3. It is faster (note: XmlElement uses Regex in it's implementation) and further speed can be gained by using a compiled Regex instance. 4. No need to worry about null references (what if the desired element doesn't exist?) 5. It is light compared to XmlElement.Parse() 6. If you need to know if the item was found, you can use the MatchEvaluator overload and an anonymous delegate -- still one line of code.