[squeak-dev] regex
Casimiro de Almeida Barreto
casimiro.barreto at gmail.com
Mon Jun 7 18:52:51 UTC 2010
Btw, in my last e-mail I meant something simpler than:
| mx0 mx1 str oc |
Transcrit clear.
mx0 := RxMatcher forString:
'(\d+)\s(\d\d)/(\d\d)/(\d\d\d\d)\s((\d+\s)+)(\d+)'.
mx1 := RxMatcher forString: '(\d+)\s'.
str := '1 27/05/1963 10 22 31 01 06 04 19 10 111'.
(mx0 matches: str)
ifFalse: [ Transcript show: 'mx0 failed to match: ',str; cr ]
ifTrue: [
Transcript show: 'Identified ',mx0 subexpressionCount asString,'
subexpressions.'; cr.
Transcript show: 'Id: ',(mx0 subexpression: 2); cr.
Transcript show: 'Date: ',(mx0 subexpression: 3),'/',(mx0
subexpression: 4),'/',(mx0 subexpression: 5); cr.
Transcript show: 'Numbers: ',(mx0 subexpression: 6); cr.
Transcript show: 'Acct: ',(mx0 subexpression: 8); cr.
oc := mx1 matchesIn: (mx0 subexpression: 6).
oc isNil
ifTrue: [
Transcript show: 'mx1 failed to match: ',(mx0 subexpression: 6);
cr ]
ifFalse: [
1 to: oc size do: [ :i |
Transcript show: 'Nb(',i asString,') = ',(oc at: i); cr ]]].
Which is just too much text for little action...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100607/fe4e74dc/signature.pgp
More information about the Squeak-dev
mailing list
|