大家讲道理2017-04-17 12:08:25
Let me explain why the regular expression above 氪 can succeed.
$number replaces the matched number group with a replacement expression, which returns the stored value found during pattern matching. of the nine most recent parts. Each time a successful bracketed match occurs, the values of the $1...$9 attributes are modified. Any number of parenthesized submatches can be specified in a regular expression pattern, but can only store the latest nine
For example
Regular expression/(w+)@(w+).(w+)/g
Text to be matchedadress helloworld@gmail.com
Here = helloworld , S2 = gmail , =com
Use $1 in replace to refer to the first saved submatch. If there are multiple submatches, you can use $2, $3, etc. to continue to reference
such as
public static void Main()
{
string s = "1 12 3 5";
s = Regex.Replace(s,@"(\d+)(?#这个是注释)","0",RegexOptions.Compiled|RegexOptions.IgnoreCase);
Console.WriteLine(s);
Console.ReadLine();
}
Output result: 01 012 03 05
Using your text, the Chinese character in the middle will be replaced with $1, each time it is replaced with $1, which is the corresponding text
ringa_lee2017-04-17 12:08:25
I know the answer. A master in the Q group taught me: replace QSTR("(.*)") with QSTR(tr("$1"))