Help with Regex

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with Regex

Torsten Bergmann
Does that help:

   '20 31 64 33 99 12 32 11 44 16 99 41' splitOn: Character space  


bye
T.

--
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl

Reply | Threaded
Open this post in threaded view
|

Re: Help with Regex

CdAB63
Em 07-06-2010 16:02, Torsten Bergmann escreveu:
Does that help:

   '20 31 64 33 99 12 32 11 44 16 99 41' splitOn: Character space  


bye
T.

  
In fact I must ensure everything are digits & spaces... what I did was just parse the whole line (id, date, seq of key codes, final sec code) using:

mx0 := RxMatcher forString: '(\d+)\s(\d\d)/(\d\d)/(\d\d\d\d)\s((\d+\s)+)(\d+)'.
mx1 := RxMatcher forString: '(\d+)\s'.

line := anOpenStream nextLine.
mx0 matches: line.
codes := mx1 matchesIn: (mx0 subexpression: 6).
...
1 to: codes size do: [ :i |
    newCodes addLast: (codes at: i) asInteger ].
^newCodes asIntegerArray.


Thanks,

CdAB



signature.asc (269 bytes) Download Attachment