From 4c92ff2fa92b487414de4ebdd87dbbe453cd2fdc Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Wed, 15 Aug 2018 14:14:56 +0200 Subject: [PATCH] Add ingo#regexp#deconstruct#RemoveMultis() --- autoload/ingo/regexp/deconstruct.vim | 18 ++++++++++++++++++ .../regexp/deconstruct/t1100-RemoveMultis.vim | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/regexp/deconstruct/t1100-RemoveMultis.vim diff --git a/autoload/ingo/regexp/deconstruct.vim b/autoload/ingo/regexp/deconstruct.vim index 86dac8f..09aed45 100644 --- a/autoload/ingo/regexp/deconstruct.vim +++ b/autoload/ingo/regexp/deconstruct.vim @@ -27,6 +27,24 @@ function! ingo#regexp#deconstruct#RemovePositionAtoms( pattern ) return substitute(a:pattern, '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@]\|_\^\|_\$\|%[\^$V#]\|%[<>]\?''.\|%[<>]\?\d\+[lcv]\)\|[\^$]\)', '', 'g') endfunction +function! ingo#regexp#deconstruct#RemoveMultis( pattern ) +"****************************************************************************** +"* PURPOSE: +" Remove multi items (*, \+, etc.) that signify the multiplicity of the +" previous atom from a:pattern. +"* 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: +" Modified a:pattern with multi items removed. +"****************************************************************************** + return substitute(a:pattern, '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@\|=\|!\|<=\|