Monday, January 25, 2016

Re: Regex issue with \|-concatenation

On 24.01.16 12:14, A. B. wrote:
> Hello Vim-users,
>
> I've try to construct a regex to find the jumping positions of the )-movement.
> Unfortunately I can not concatenate two patterns with \|.

Concats are separated by \&.
\| separates branches. See :h regex.

In general regex terms, | can be used thus:

(expression made an atom by the parentheses)|(and another one)

The whole regex will match if any of the branches do.

> My whole pattern looks like this:
> '.\n\zs\_^\_$\|[.!?][]]*\(\s\+\n\=\|\n\s*\)\(\s\+\n\)*\zs\S\|\_^\_$\n\s*\zs\S\|\%$'

The low level of magic you're using obscures the underlying regex in an
unreadable backslash storm. (:h magic : \v cleans up all that crap, and
brings Vim very close to Posix regex conformity.)
Hopefully my general advice will put you on the right track, though.

Erik

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: