DervishD <[EMAIL PROTECTED]> writes: > Hello all :) > > I'm using coreutils 5.2.1 and I've noticed a weird behaviour of > 'expr'. I don't know if it's my fault, but a command like: > > $ expr "x" : "[:alpha:]"
This matches "x" against the set of characters ":ahlp". > returns 0 instead of 1, but a command like: > > $ expr "x" : "[[:alpha:]]" This matches "x" against the set of characters from the character class "alpha". > returns 1, correctly. That is, 'expr' understands character > classes but it needs that double bracket :( The syntax of a character class is [:CLASS:], _including_ the brackets. Thus to build a regular expression that matches a single lower case letter or digit or underscore, you write "[[:lower:][:digit:]_]". > This is non portable AFAIK, at least is not SUSv3 compliant regarding > basic regular expressions Please read again. > and other binaries like 'tr' `tr' doesn't expect regular expressions as arguments, but rather they are interpreted as character sets without the surrounding brackets. > Am I doing something wrong? You are mixing the syntax for a regular expression containing a character set with the syntax for a character class inside a character set. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils