【发布时间】:2019-01-03 00:57:05
【问题描述】:
正在搜索的字符串
“遇到(大)问题做其他事情bla bla,请参阅日志 文件:“
如果存在,模式应该找到“(something-big) issues”的确切子字符串。
如何在正则表达式模式中允许括号
我尝试过的这种模式失败了
\b\(something-big\) issues\b
例如。
$str2 = "ran into (something-big) issues do something else bla bla, see log file: ";
if($str2 -match '\b\(something-big\) issues\b' ) {
Write-Output "we found it";
}
else{
Write-Output "nope";
}
【问题讨论】:
-
这行得通 ---
$str2 -match '\(something-big\) issues'。我不知道为什么你的失败,寿。 [脸红]
标签: regex powershell