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

  • Thread starter Sam Kon via .NET 247
  • 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.
 
N

Nicholas Paldino [.NET/C# MVP]

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?
 
K

KG

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top