bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5812: expr: Difference in behavior of match and :


From: Adil Mujeeb
Subject: bug#5812: expr: Difference in behavior of match and :
Date: Wed, 31 Mar 2010 18:35:16 +0530

Hello team,

I have tried following snippet in a bash script:

-bash-3.1$userid=`expr "uid=11008(ADILM) gid=1200(cvs),1400(build)" :
".*uid=[0-9]*(\(.[0-9a-z]*\)) .*"`
-bash-3.1$echo $userid
ADILM
-bash-3.1$

To my knowledge it should not able to extract ADILM as the regex does not
include uppercase letters (A-Z).

In the expr man page it is mentioned that:

-----8<----------
match STRING REGEXP
 same as STRING : REGEXP
-----8<----------

So i tried following snippet:-

-bash-3.1$ userid=`expr match "uid=11008(ADILM) gid=1200(cvs),1400(build)"
".*uid=[0-9]*(\(.[0-9a-z]*\)) .*"`
-bash-3.1$ echo $userid

-bash-3.1$

I changed the regex and added uppercase letters:-
-bash-3.1$ userid=`expr match "uid=11008(ADILM) gid=1200(cvs),1400(build)"
".*uid=[0-9]*(\(.[0-9A-Za-z]*\)) .*"`
-bash-3.1$ echo $userid
ADILM
-bash-3.1$

So it means that match is not same as ":". As per observation ":" uses
case-insensitive matching while match is strict case sensitive matching.

Can you update the man page OR let me know if i am doing anything wrong?

Package:-
-bash-3.1$ rpm -qf /usr/bin/expr
coreutils-5.97-12.1.el5
-bash-3.1$

Thanks and Regards,
Adil Mujeeb


reply via email to

[Prev in Thread] Current Thread [Next in Thread]