正则表达式以确保单词GO
本文关键字:GO 保单 确保 正则表达式 | 更新日期: 2023-09-27 18:21:59
我正在读取文本文件中的所有行。如何确保正则表达式中单词GO
是行中唯一的单词?
stringsIgnore = "GO ALGORITHM";
stringsCorrect = "GO";
Regex.Match("GO", "GO");
锚定正则表达式,表示它适用于整行:
^GO$
不需要使用Regex。。。
var line = streamReader.ReadLine();
if( line == "GO" )
{
}
Regex regex = new Regex("^GO$", RegexOptions.IgnoreCase), RegexOptions.IgnoreCase);
Match match = regex.Match(text);
while (match.Success)
{
// Logic
match = match.NextMatch();
}
Regex.Match([您的输入字符串],"''bGO''b")