" ingo/regexp/split.vim: Functions to split a regular expression. " " DEPENDENCIES: " - ingo/collections.vim autoload script " - ingo/regexp/length.vim autoload script " - ingo/regexp/magic.vim autoload script " " Copyright: (C) 2017-2018 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat function! ingo#regexp#split#TopLevelBranches( pattern ) "****************************************************************************** "* PURPOSE: " Split a:pattern on "\|" - separated branches, keeping nested \(...\|...\) " branches inside (non-)capture groups together. If the complete a:pattern is " wrapped in a group, it is treated as one toplevel branch, too. "* ASSUMPTIONS / PRECONDITIONS: " Does not consider "very magic" (/\v)-style syntax (...|...). If you may have " this, convert via ingo#regexp#magic#Normalize() first. "* EFFECTS / POSTCONDITIONS: " None. "* INPUTS: " a:pattern regular expression "* RETURN VALUES: " List of regular expression branch fragments. "****************************************************************************** let l:rawBranches = split(a:pattern, '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@