Sunday, August 14, 2022

Re: Regex with backslashes in a collection

/\(\\[\|\\\]\)

No magic or anything set as you can see. Matches \[ or \]. 

Regards.

lør. 13. aug. 2022, 9:24 a.m. skrev JohnBeckett <johnb.beckett@gmail.com>:
I'm using Vim 8 or 9 with 'magic' and re=0 (same using re=1).

I want to find "\[" or "\]" in text like:
abc\[def\]ghi\\xy\z

The following pattern also find the two backslashes.
\\[\[\]]

Help says that a backslash in a collection (if not followed
by certain characters) just means a backslash.
:help /\]

Why does the pattern find two backslashes (but not one)?

These patterns find only "\]" (good):
\\[\]]
\\[]]

But this finds "\[" and "\\" (not "\"):
\\[\[]

John

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/88494085-43a9-46d8-a58b-f35981545112n%40googlegroups.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAL3odWwV0x0K8U8u7%3DFbmsZAKtU-QozsNSf8RtBcNA%3DdK28VUg%40mail.gmail.com.

No comments: