mirror of
https://github.com/inkarkat/vim-ingo-library.git
synced 2026-05-29 11:18:51 +02:00
Add ingo#str#trcd() variant of ingo#str#trd()
This commit is contained in:
@@ -159,6 +159,7 @@ HISTORY
|
||||
- Add optional a:Predicate argument to ingo#area#frompattern#Get() and
|
||||
ingo#text#frompattern#Get(). Additionally, the a:isOnlyFirstMatch and
|
||||
a:isUnique arguments are optional now, too.
|
||||
- Add ingo#str#trcd() variant of ingo#str#trd().
|
||||
|
||||
##### 1.040 31-Oct-2019
|
||||
- Add ingo#str#TrimTrailing() variant of ingo#str#Trim().
|
||||
|
||||
+20
-1
@@ -5,7 +5,7 @@
|
||||
" - ingo/regexp/virtcols.vim autoload script
|
||||
" - ingo/str/list.vim autoload script
|
||||
"
|
||||
" Copyright: (C) 2013-2019 Ingo Karkat
|
||||
" Copyright: (C) 2013-2020 Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
@@ -141,6 +141,25 @@ function! ingo#str#trd( src, fromstr )
|
||||
return substitute(a:src, '\C' . ingo#regexp#collection#LiteralToRegexp(a:fromstr), '', 'g')
|
||||
endfunction
|
||||
|
||||
function! ingo#str#trcd( src, fromstr )
|
||||
"******************************************************************************
|
||||
"* PURPOSE:
|
||||
" Keep only characters in a:fromstr in a copy of a:src. Like tr -cd, but the
|
||||
" built-in tr() doesn't support this.
|
||||
"* ASSUMPTIONS / PRECONDITIONS:
|
||||
" None.
|
||||
"* EFFECTS / POSTCONDITIONS:
|
||||
" None.
|
||||
"* INPUTS:
|
||||
" a:src Source string.
|
||||
" a:fromstr Characters that will each be kept in a:src.
|
||||
"* RETURN VALUES:
|
||||
" Copy of a:src that has all instances of the complement of the characters in
|
||||
" a:fromstr removed.
|
||||
"******************************************************************************
|
||||
return substitute(a:src, '\C[^' . ingo#regexp#collection#LiteralToRegexp(a:fromstr)[1:], '', 'g')
|
||||
endfunction
|
||||
|
||||
function! ingo#str#Wrap( string, commonOrPrefix, ... ) abort
|
||||
"******************************************************************************
|
||||
"* PURPOSE:
|
||||
|
||||
@@ -174,6 +174,7 @@ HISTORY *ingo-library-history*
|
||||
- Add optional a:Predicate argument to ingo#area#frompattern#Get() and
|
||||
ingo#text#frompattern#Get(). Additionally, the a:isOnlyFirstMatch and
|
||||
a:isUnique arguments are optional now, too.
|
||||
- Add ingo#str#trcd() variant of ingo#str#trd().
|
||||
|
||||
1.040 31-Oct-2019
|
||||
- Add ingo#str#TrimTrailing() variant of ingo#str#Trim().
|
||||
|
||||
Reference in New Issue
Block a user