Hi Matthew

Matthew Kim wrote:
<..>
> Basically I'm trying to do this...
> 
> Mobile Email Address: [EMAIL PROTECTED]
> 
> <Parsing algorithm>
> 
> Result:
> ~~~~~~~~~~~~~~~~~~~~~~~
> Area Code: 416
> Phone Number: 5551234

You could use parse ...

 >> mea: [EMAIL PROTECTED]
== [EMAIL PROTECTED]
 >> parse mea [ copy area 3 skip copy phone to "@" to end ]
== true
 >> area
== "416"
 >> phone
== "5551234"

This rule would be happy to parse anything with an "@" symbol and at 
least 3 characters before it. If you want to check, if this is really a 
mobile phone number, you can change it like this:

 >> digit: charset [ #"0" - #"9" ]
== make bitset! #{
000000000000FF03000000000000000000000000000000000000000000000000
}
 >> parse mea [ copy area2 3 digit copy phone2 6 8 digit "@" to end ]
== true
 >> area2
== "416"
 >> phone2
== "5551234"

Now you can be sure, that there are only digits before the "@" and at 
least 3 for the area and 6 for the phone number, at most 8 for the phone 
number.


I hope that helped,

Ingo


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to