diff options
| author | Peter Stephenson <pws@users.sourceforge.net> | 2010-01-18 12:47:09 +0000 |
|---|---|---|
| committer | Peter Stephenson <pws@users.sourceforge.net> | 2010-01-18 12:47:09 +0000 |
| commit | c508c6e368ac7faef55a16d9c85a2fbdd21232fc (patch) | |
| tree | c46f72ce11b8485f052698b94485bc95bfae77f3 /Functions/Zle/replace-string-again | |
| parent | 27600: extend =~ syntax to set positional variables for matches (diff) | |
| download | zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.gz zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.bz2 zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.lz zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.xz zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.tar.zst zsh-c508c6e368ac7faef55a16d9c85a2fbdd21232fc.zip | |
27604: substitution using regular expressions
Diffstat (limited to 'Functions/Zle/replace-string-again')
| -rw-r--r-- | Functions/Zle/replace-string-again | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Functions/Zle/replace-string-again b/Functions/Zle/replace-string-again index 3d3486437..8f4d23854 100644 --- a/Functions/Zle/replace-string-again +++ b/Functions/Zle/replace-string-again @@ -13,7 +13,7 @@ if [[ -z $_replace_string_src ]]; then return 1 fi -if [[ $curwidget = *pattern* ]]; then +if [[ $curwidget = *(pattern|regex)* ]]; then local rep2 # The following horror is so that an & preceded by an even # number of backslashes is active, without stripping backslashes, @@ -38,8 +38,14 @@ if [[ $curwidget = *pattern* ]]; then rep=${match[5]} done rep2+=$rep - LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} - RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} + if [[ $curwidget = *regex* ]]; then + autoload -U regexp-replace + regexp-replace LBUFFER $_replace_string_src $rep2 + regexp-replace RBUFFER $_replace_string_src $rep2 + else + LBUFFER=${LBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} + RBUFFER=${RBUFFER//(#bm)$~_replace_string_src/${(e)rep2}} + fi else LBUFFER=${LBUFFER//$_replace_string_src/$_replace_string_rep} RBUFFER=${RBUFFER//$_replace_string_src/$_replace_string_rep} |
