zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Example of use of (S) flag
Date: Wed, 23 Dec 2015 21:01:57 -0800	[thread overview]
Message-ID: <151223210157.ZM447@torch.brasslantern.com> (raw)
In-Reply-To: <20151223232519.GA9602@chaz.gmail.com>

On Dec 23, 11:25pm, Stephane Chazelas wrote:
} Subject: Re: Example of use of (S) flag
}
} 2015-12-23 19:25:05 +0100, Sebastian Gniazdowski:
} > Hello,
} > completion says that (S) is "search substrings in #, %, /
} > expressions". Can someone provide example of (S) influence? Thanks
} [...]
} 
} $ a=ababa
} $ echo ${(S)a#b}
} aaba
} $ echo ${(S)a%b}
} abaa

Note also that ${(S)var:#pat} is not useful; pat must still match the
entire value of $var (or an element of $var in the array case) for the
element to be matched/removed.

Further note that (MS) is sort of a dumbed-down form of backreferences,
returning something similar to the value of $MATCH in an extendeglob
pattern that uses (#m) (except extendedglob is not needed).  E.g.:

% a=abcba
% echo ${(MS)a#b?}
bc
% echo ${(MS)a%b?}
ba

Here are some examples of the use with ${var/pat/repl}:

torch% echo ${a/b*/x}    
ax
torch% echo ${(S)a/b*/x}
axcba
torch% echo ${(S)a//b*/x}
axcxa


  reply	other threads:[~2015-12-24  5:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAKc7PVBLdXYQ_NNU9q=v9TcfiZjsYKfDt2h=ZBdfGCt6t81cuQ__14537.6145992943$1450895198$gmane$org@mail.gmail.com>
2015-12-23 23:25 ` Stephane Chazelas
2015-12-24  5:01   ` Bart Schaefer [this message]
2015-12-24  7:53     ` Sebastian Gniazdowski
2015-12-28 18:23     ` Philippe Troin
2015-12-28 19:13       ` Mikael Magnusson
2015-12-23 18:25 Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151223210157.ZM447@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).