I have text saved in a variable, for example, like this:
let text = getline(line(".")-1)
How do I check if the text matches a regular expression? I'm expecting something like this:
let text = getline(line(".")-1)
if regexp_match(text, "^[Ss]tuff$")
dostuff
endif
Made some more research and found out that what I needed is =~# operator which is used to check if some text matches a regexp:
if "text"=~#"^te.."
echo "Matches!"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With