C# 字符串的正则表达式
我有一根像 e、 g AHDFFH XXXX 其中“AHDFFH”可以是任意长度的字符字符串。 “XXXX”将是重复的任意长度的“X”字符数,需要在表中用自动递增的数据库值替换 我需要使用正则表达式从上面的字符串中找到重复的“X”字符C# 字符串的正则表达式,c#,regex,C#,Regex,我有一根像 e、 g AHDFFH XXXX 其中“AHDFFH”可以是任意长度的字符字符串。 “XXXX”将是重复的任意长度的“X”字符数,需要在表中用自动递增的数据库值替换 我需要使用正则表达式从上面的字符串中找到重复的“X”字符 有人能帮我弄清楚吗?。试试这个: \b(\p{L})\1+\b <!-- \b(\p{L})\1+\b Options: case insensitive; ^ and $ match at line breaks Assert position at
有人能帮我弄清楚吗?。试试这个:
\b(\p{L})\1+\b
<!--
\b(\p{L})\1+\b
Options: case insensitive; ^ and $ match at line breaks
Assert position at a word boundary «\b»
Match the regular expression below and capture its match into backreference number 1 «(\p{L})»
A character with the Unicode property “letter” (any kind of letter from any language) «\p{L}»
Match the same text as most recently matched by capturing group number 1 «\1+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert position at a word boundary «\b»
-->
说明:
\b(\p{L})\1+\b
<!--
\b(\p{L})\1+\b
Options: case insensitive; ^ and $ match at line breaks
Assert position at a word boundary «\b»
Match the regular expression below and capture its match into backreference number 1 «(\p{L})»
A character with the Unicode property “letter” (any kind of letter from any language) «\p{L}»
Match the same text as most recently matched by capturing group number 1 «\1+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert position at a word boundary «\b»
-->
您的意思是一些字符+(在或一些)空格+一些数字吗 如果是,您可以使用此正则表达式:
\w+\s+(\d+)
c#代码如下:
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\w+\s+(\d+)");
System.Text.RegularExpressions.Match m = regex.Match("aaaa 3333");
if(m.Success) {
MessageBox.Show(m.Groups[1].Value);
}
这可能会对你有所帮助。我建议你发布一些你正在使用的实际模式。