3

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).

Thanks.

1 Answer 1

4

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

getreg('o')

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.

See

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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