pattern syntax for match()

7 views
Skip to first unread message

S. Cowles

unread,
3:28 PM (3 hours ago) 3:28 PM
to vim...@googlegroups.com


i would like to do the following operation:
let m = match( "foo" , "foo\|beep" )
however, i get no match. (m is (-1).)
what is the correct pattern syntax to enable this match?
i am running vim:
VIM - Vi IMproved 9.2 (2026 Feb 14, compiled Mar 25 2026 09:59:45)
Included patches: 1-240
Huge version with GTK3 GUI.

thanks.

--
s. cowles
scowles at sonic dot net
Key fingerprint = 6DEC FF05 6952 3967 BE66 1BBD 588D 8B40 EFB8 4AA2


Tim Chase

unread,
3:37 PM (3 hours ago) 3:37 PM
to vim...@googlegroups.com
On 2026-03-25 12:01, S. Cowles wrote:
> i would like to do the following operation:
> let m = match( "foo" , "foo\|beep" )
> however, i get no match. (m is (-1).)
> what is the correct pattern syntax to enable this match?

Because they're strings, do you need to escape the "\", making it

let m = match( "foo" , "foo\\|beep" )

-tim
--





Christian Brabandt

unread,
3:43 PM (3 hours ago) 3:43 PM
to vim...@googlegroups.com
Or a bit more readable, use single quotes instead.

Thanks,
Christian
--
Are we not men?

scowles

unread,
4:19 PM (2 hours ago) 4:19 PM
to vim...@googlegroups.com

tim / christian

thank you.  both forms work as expected:  single and double quoted forms.  in all of my quoting permutations, i had been escaping the bar, also.

works fine, now.  many thanks.
Reply all
Reply to author
Forward
0 new messages