Saturday, August 13, 2022

Regex with backslashes in a collection

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.

No comments:

Post a Comment