How to replace a pattern in a html file using C#?

  • Thread starter Thread starter Sam Kon via .NET 247
  • Start date Start date
S

Sam Kon via .NET 247

Can any one of you let me know, how can I replace a pattern in an html file using C#?
I have the contents of the html file stored in a string. I just need to replace some of the elements which have a similar pattern?
ex: I have a field {Token = LoanNumber} in the html file.
I just need to replace Loan Number with some text by finding the pattern "{Token=".
Any suggestions are welcome.
Thanks.
 
Sam,

I would definitely look at regular expressions for this. I don't know
exactly which expression you would use, but you would get the best
performance (probably).

Perhaps someone else can point out which RegEx he would want to use?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sam Kon via .NET 247 said:
Can any one of you let me know, how can I replace a pattern in an html file using C#?
I have the contents of the html file stored in a string. I just need to
replace some of the elements which have a similar pattern?
 
Sam Kon via .NET 247 said:
Can any one of you let me know, how can I replace a pattern in an html file using C#?
I have the contents of the html file stored in a string. I just need to
replace some of the elements which have a similar pattern?
ex: I have a field {Token = LoanNumber} in the html file.
I just need to replace Loan Number with some text by finding the pattern "{Token=".
Any suggestions are welcome.
Thanks.

As Nicholas said, try regex.
RegexLib.com has good examples

http://regexlib.com
 
Back
Top