The below regex condition is matching the below website Regex pattern
以下正则表达式条件匹配以下网站正则表达式模式
Input[\s?[ABCD]+\s?(,\s?[-*][0-9]+%)?](?=\s)
Website link: http://regexr.com/
网站链接:http://regexr.com/
But in my WPF application the same Regex is not working.
但在我的WPF应用程序中,相同的Regex无效。
Code snippet
if( Regex.Match(this.textBox.Text, "Input\\[\\s?[ABCD] +\\s ? (,\\s?[-*][0 - 9] +%)?\\](?=\\s)|[?=\\t] |[?=\\s]").Success)
{
MessageBox.Show("Regex matched");
}
Can anyone please suggest, How can we proceed on this?
任何人都可以建议,我们如何处理这个?
1 个解决方案
#1
3
But in my WPF application the same Regex is not working.
但在我的WPF应用程序中,相同的Regex无效。
No. It's not the same regex, there's an additional \
after Input
in your C# app. This is the same:
不。它不是相同的正则表达式,在C#应用程序中输入后还有一个额外的\。这是一样的:
if( Regex.Match(this.textBox.Text, @"Input\[\s?[ABCD]+\s?(,\s?[-*][0-9]+%)?\](?=\s)").Success)
{
MessageBox.Show("Regex matched");
}
#1
3
But in my WPF application the same Regex is not working.
但在我的WPF应用程序中,相同的Regex无效。
No. It's not the same regex, there's an additional \
after Input
in your C# app. This is the same:
不。它不是相同的正则表达式,在C#应用程序中输入后还有一个额外的\。这是一样的:
if( Regex.Match(this.textBox.Text, @"Input\[\s?[ABCD]+\s?(,\s?[-*][0-9]+%)?\](?=\s)").Success)
{
MessageBox.Show("Regex matched");
}