| www.delorie.com/gnu/docs/sh-utils/sh-utils_27.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
expr supports pattern matching and other string operators. These
have lower precedence than both the numeric and relational operators (in
the next sections).
grep) regular
expression, with a ^ implicitly prepended. The first argument is
then matched against this regular expression.
If the match succeeds and regex uses `\(' and `\)', the
: expression returns the part of string that matched the
subexpression; otherwise, it returns the number of characters matched.
If the match fails, the : operator returns the null string if
`\(' and `\)' are used in regex, otherwise 0.
Only the first `\( ... \)' pair is relevant to the return value; additional pairs are meaningful only for grouping the regular expression operators.
In the regular expression, \+, \?, and \| are
operators which respectively match one or more, zero or one, or separate
alternatives. SunOS and other expr's treat these as regular
characters. (POSIX allows either behavior.)
See section `Regular Expression Library' in Regex, for details of
regular expression syntax. Some examples are in 5.4.4 Examples of using expr.
/.
This makes it possible to test expr length quote "$x" or
expr quote "$x" : '.*/\(.\)' and have it do the right thing even if
the value of $x happens to be (for example) / or index.
This operator is a GNU extension. It is disabled when
the environment variable POSIXLY_CORRECT is set.
To make expr interpret keywords as strings, you must use the
quote operator.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |