GNU bug report logs -
#5812
expr: Difference in behavior of match and :
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 4 Apr 2010 22:42:13 -0600
with message-id <20100405044212.GA22010 <at> dementia.proulx.com>
and subject line Re: bug#5812: expr: Difference in behavior of match and :
has caused the GNU bug report #5812,
regarding expr: Difference in behavior of match and :
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact help-debbugs <at> gnu.org
immediately.)
--
5812: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5812
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
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
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
Adil Mujeeb wrote:
> Thanks Bob for such a nice explanation and your instinct is right. It is
> locale problem.
> ...
> And the other point you made is also right. I didn’t realize that I was
> using another session for comparing the result with match which ahs
> different locale:-
I thought it might have been something like that.
> I never knew that locale has effect on the behavior. We can close this bug.
I will close the bug with this message then.
> Thank you so much for your time and details, I have learnt new thing :)
I am glad to have helped!
> Also, thanks for correcting my regex.
Sure thing!
Bob
This bug report was last modified 15 years and 110 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.