Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] More Parsing questions

From: syke:amigaextreme at: 6-Sep-2001 7:04

Hi list, as usual, I'm having parsin troubles. Here's what I'm trying to do: I have a regular text file containing names, with phone numbers, like this: John Doe 5694 Jane Doe 0445-38352 etc.. (I read it in using read/lines) what I want to do is to find all the lines that only have four digits in them, the other ones should be ignored. So I tried this:
>> data: "Ebba Grön 2345"
== "Ebba Grön 2345"
>> parse data [to "2345" to end]
== true And after that, I tried this:
>> digit: charset "0123456789"
== make bitset! #{ 000000000000FF03000000000000000000000000000000000000000000000000 }
>> parse data [to 4 digit to end]
== false Why does this become false? What I want to do is, if parse returns true, it should copy the entire line, add a newline to that line, and then save the file. I realise that this parse rule will find lines containing for example 6 digits in a row, but I guess it's a start. This is what I'd like to achieve: foreach line data [ if (parse line [to 4 digit to end]) [append new-data (rejoin [ line newline])] ] Or something similar, the trick is to get the lines that contain only 4 digits, not the ones containing 5 or more digits (no matter what order they are in, xxx-xxxxxxx, xxxxxxx, or anything else). /Regards Stefan Falk www.amigaextreme.com