Sunday, August 14, 2022

Re: Regex with backslashes in a collection

On 2022-08-14, JohnBeckett wrote:
> > [\[] is a collection containing two characters, \ and [
>
> Yes, that's what my test shows. The problem is that the pattern \\[\[] finds "\
> \" and "\[" but not "\".

Right. Your pattern says to find a \ followed by one of the
items of the collection containing \ and [. So, it will match
either of

\\
\[

but not a single \ unless it is immediately followed by a [. If you
want it to also match a single \, you could use this:

\\[\[]\?

which will match \ followed by zero or one of \ or [.

Regards,
Gary

--
--
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/20220814172802.GP12539%40phoenix.

No comments: