需要将$ string1与PowerShell中的某个字符串模板进行比较
rotacao_esq
模板和上面的字符串有什么问题? 谢谢!
答案 0 :(得分:2)
-match
运算符不可交换,因此无法切换操作数。第一个操作数必须是要与正则表达式匹配的字符串,第二个操作数必须是正则表达式。此外,正则表达式中的双反斜杠计算为文字反斜杠而不是转义特殊字符。
改变这个:
$string1 = '\\<a href="main\\.php\\?act=forum\\&hdl=read_\\&id=(\d+)\\&pid=313" class="small_name2"\\>Learn the powershell tool\\</a\\>'
$string1 -match '<a href="main.php?act=forum&hdl=read_&id=83523&pid=313" class="small_name2">Learn the powershell tool</a>'
进入这个:
$string1 = '\<a href="main\.php\?act=forum\&hdl=read_\&id=(\d+)\&pid=313" class="small_name2"\>Learn the powershell tool\</a\>'
'<a href="main.php?act=forum&hdl=read_&id=83523&pid=313" class="small_name2">Learn the powershell tool</a>' -match $string1