In addition to my previous reply I looked at the value assigned to d. The
~(X)-mode always drops the first digit of "15" and sets \2 to \1
cp003421_run> ksh -c 'x="a15 b2 c3" ;
d="${x//+([[:alnum:]]&[[:digit:]])/X\1Y\2}" ; print -v .sh.match;print $d'
(
(
15
2
3
)
(
15
2
3
)
)
aX15Y\2 bX2Y\2 cX3Y\2
cp003421_run> ksh -c 'x="a15 b2 c3" ;
d="${x//~(X)([[:alnum:]]&[[:digit:]])+/X\1Y\2}" ; print -v .sh.match;print $d'
(
(
15
2
3
)
(
5
2
3
)
)
aX5Y\2 bX2Y\2 cX3Y\2
cp003421_run> ksh -c 'x="a15 b2 c3" ;
d="${x//~(X)(([[:alnum:]])&([[:digit:]]))+/X\1Y\2}" ; print -v .sh.match;print
$d'
(
(
15
2
3
)
(
5
2
3
)
(
5
2
3
)
(
5
2
3
)
)
aX5Y5 bX2Y2 cX3Y3
~(K) should be the default, so adding it should make difference, however it does
cp003421_run> ksh -c 'x="a15 b2 c3" ;
d="${x//~(K)+([[:alnum:]]&[[:digit:]])/X\1Y\2}" ; print -v .sh.match;print $d'
a15 b2 c3
These effects are version independent
Best Regards
Axel Philipp
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Dan Shelton
Gesendet: Dienstag, 20. August 2013 22:32
An: [email protected]; [email protected]
Betreff: [ast-users] Bug in ~(X) and .sh.match
I may have found a bug in ~(X). AFAIK the first index (.sh.match[0])
in .sh.match always lists all patterns for which matches have been
found, and all following indexes (.sh.match[0..inf]) store the
captured matches for a specific bracket pair, right?
If that's correct, why does '15' appear in .sh.match[0][0] but no
other match has '15' later?
ksh -c 'x="a15 b2 c3" ; d="${x//~(X)(([[:alnum:]])&([[:digit:]]))+/}"
; print -v .sh.match'
(
(
15
2
3
)
(
5
2
3
)
(
5
2
3
)
(
5
2
3
)
)
Dan
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users
--
MTU Aero Engines AG
Geschaeftsfuehrung/Board of Management: Egon W. Behle, Vorsitzender/CEO; Dr.
Rainer Martens, Michael Schreyögg, Dr. Stefan Weingartner, Reiner Winkler
Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Klaus
Eberhardt
Sitz der Gesellschaft/Registered Office: Muenchen
Handelsregister/Commercial Register: Muenchen HRB 157206
Diese E-Mail sowie ihre Anhaenge enthalten MTU-eigene vertrauliche oder
rechtlich geschuetzte Informationen.
Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte den
Absender und loeschen Sie diese
E-Mail sowie die Anhaenge. Das unbefugte Speichern, Kopieren oder Weiterleiten
ist nicht gestattet.
This e-mail and any attached documents are proprietary to MTU, confidential or
protected by law.
If you are not the intended recipient, please advise the sender and delete this
message and its attachments.
Any unauthorised storing, copying or distribution is prohibited.
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users