pattern syntax for match()

12 views
Skip to first unread message

S. Cowles

unread,
Mar 25, 2026, 3:28:46 PM (12 hours ago) Mar 25
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,
Mar 25, 2026, 3:37:32 PM (12 hours ago) Mar 25
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,
Mar 25, 2026, 3:43:29 PM (12 hours ago) Mar 25
to vim...@googlegroups.com
Or a bit more readable, use single quotes instead.

Thanks,
Christian
--
Are we not men?

scowles

unread,
Mar 25, 2026, 4:19:46 PM (11 hours ago) Mar 25
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