0

How can I replace a certain part in a html string variable with a definied string?

var htmlvar = "<td style=\"border-width: 0px;\" align=\"left\" id=\"tdPassword\">@Model.Password</td>"

that the result looks like that:

var htmlvar = "<td style=\"border-width: 0px;\" align=\"left\" id=\"tdPassword\">*******</td>"

I'm using c# .net 3.5 and I thougt of a regex solution.

Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
Diana Dimitrova
  • 135
  • 2
  • 16

2 Answers2

0

Use

(?<start>\<td[^\>]*\>)[^\<]*(?<end></td>)

to match, and

$1****$2

for replacement.

Ria
  • 10,237
  • 3
  • 33
  • 60
0

i used this comment content to solve it: Use the html agility pack: htmlagilitypack.codeplex.com – David Brabant 3 hours ago thanks

Diana Dimitrova
  • 135
  • 2
  • 16