[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is expr's \? regex metachar working?
From: |
Andreas Schwab |
Subject: |
Re: is expr's \? regex metachar working? |
Date: |
23 Aug 2001 16:04:53 +0200 |
User-agent: |
Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.105 |
"Clark O. Morgan" <address@hidden> writes:
|> Forgive me if this is a dup post. A previously posted copy of this article
|> hasn't shown up on aracnet's news server or on newsguy....
|>
|>
|> The info page for expr 2.0 says that with respect to the ':' operator's
|> regular expression argument:
|>
|> In the regular expression, `\+', `\?', and `\|' are operators
|> which respectively match one or more, zero or one, or separate
|> alternatives.
|>
|> I can't get `\?' to work--it always seems to return
|> the length of the target string.....
|>
|> $ ./expr --version
|> expr (GNU sh-utils) 2.0
|> Written by Mike Parker.
|>
|> $ ./expr "abcdef" : '.*b'
|> 2
|> $ ./expr "abcdef" : '.*u'
|> 0
|> $ ./expr "abcdef" : '.*u\?'
|> 6
|> $ ./expr "abcdef" : '.*b\?'
|> 6 <--- this looks wrong
No, this is correct. The '.*' regexp matches the maximum possible length,
which is all 6 characters. Since b is optional, it does not cause a match
failure.
|> $ ./expr "abcdef" : '.*z\?'
|> 6
|> $ ./expr "abcdef" : '.*\(z\)\?'
|>
|> $ ./expr "abcdef" : '.*\(b\)\?'
|> <--- this looks wrong
Same here. \(b\) is not used for matching, thus \1 is empty.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
address@hidden
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
- is expr's \? regex metachar working?, Clark O. Morgan, 2001/08/23
- Re: is expr's \? regex metachar working?,
Andreas Schwab <=
- Re: is expr's \? regex metachar working?, Clark Morgan, 2001/08/23
- Re: is expr's \? regex metachar working?, Andreas Schwab, 2001/08/23
- Re: is expr's \? regex metachar working?, Clark Morgan, 2001/08/23
- Re: is expr's \? regex metachar working?, Andreas Schwab, 2001/08/23
- Re: is expr's \? regex metachar working?, Clark Morgan, 2001/08/23
- Re: is expr's \? regex metachar working?, Andreas Schwab, 2001/08/23
- Re: is expr's \? regex metachar working?, Clark Morgan, 2001/08/23
- Re: is expr's \? regex metachar working?, Paul Jarc, 2001/08/23
Re: is expr's \? regex metachar working?, Clark O. Morgan, 2001/08/23