为字符串创建正则表达式 [英] creating regex expression for string
本文介绍了为字符串创建正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写信寻求建议,以下我在下面的Regex表达式中出错:
I am writing to seek advice, as to where I may be going wrong in the following Regex expression below:
var input = "97.2525, M45s, 130.5, +129s, 145s";
foreach(var match in Regex.Matches(input,@"\+\d+([1-9]\d{2,})\[AS]"))
{
Console.WriteLine(match);
}
此代码的输出应为以下值 + 129s,145s。
提前感谢您的帮助和时间。
the output from this code should be the following values "+129s, 145s".
Thank you in advance for your help and time.
推荐答案
尝试:
Try:
\+(\d{2,}[ASas]\,?\s?){2}
如果您打算使用Regexes,请获取 Expresso 的副本[ ^ ] - 它是免费的,它会检查并生成正则表达式。我希望我写完了!
If you are going to work with Regexes, get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions. I wish I'd written it!
这篇关于为字符串创建正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文