Regex replace expression

  • Thread starter Thread starter William A Wang
  • Start date Start date
W

William A Wang

Guest
I currently try to use Regex to replace the text to lower case for Html tags in string, here are my test codes:

using System;
using System.Text.RegularExpressions;

namespace ConsoleApp2
{
class Program
{
public static void Main()
{
string source = "<Div>Someone is here</Div>";
Regex reg = new Regex(@"<(\/?)(\w+)>");
Console.WriteLine(reg.Replace(source, @"<$1\L$2>"));
}
}
}

The console output result is: <\LDiv>Someone is here</\LDiv>, it seems it made the \L to a string.

The same match expression and replace expression cloud work correctly in this website: Regex101 - online regex editor and debugger


BR.

Continue reading...
 
Back
Top