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.
我将文本保存在变量中,例如,如下所示:
let text = getline(line(".")-1)
如何检查文本是否与正则表达式匹配?我期待这样的事情:
let text = getline(line(".")-1) if regexp_match(text, "^[Ss]tuff$") dostuff endif
进行了更多研究,发现我需要的是=~# 运算符,用于检查某些文本是否与正则表达式匹配:
if "text"=~#"^te.." echo "Matches!"