Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对以下正则表达式有疑问:
我想匹配以下字符串:employee Type="entry" id="mmop" location="somewhere" 使用 RE 如下:
employee Type="entry" id="mmop" location="somewhere"
if {[regexp {id=(".*")} $data -> Id]} { #do something here }
但我得到的结果是"entry" id="mmop" location="somewhere",如何解决?
"entry" id="mmop" location="somewhere"
?在 之后添加*,或替换.为[^"]。问题是由.*贪婪引起的,在仍然匹配模式的同时抓住一切。
?
*
.
[^"]
.*