I'm writing a new plugin and as part of a function, I need to check that a register contains a particular pattern.

I checked the official documentation but couldn't manage to use any of the search() or substitute() functions for this purpose.

Any idea how this could be done?

(Suppose the register is "o and the pattern is Image).



To get the content of the register "o you can use:


This will return the content of the register as a string.

To match a string you can use match():

echo match(getreg('o'), 'image')

You'll get -1 if the register doesn't contain image and a positive interger otherwise.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.