I am trying to replace model => model.Password substring within @Html.DisplayNameFor(model => model.Password).
Any clue which regex template I have use to?
I have tried \\(.+?\\) Is this correct?
Thank you!
var match = Regex.Match(view, @"@Html.DisplayNameFor(\\(.+?\\))", RegexOptions.IgnoreCase);
if (match.Success)
{
}
The pattern should be more like:
Since you were already using a verbatim string (
@""), you shouldn’t have included the double backslashes. Also, the.should have been escaped, and I adjusted the grouping parens to matchmodel => model.Passwordinstead of(model => model.Password).And if you’re trying to replace, you may want to just use
Regex.Replacedirectly instead of firstMatching it.