[vwnc] Smalltalk equivalent for sscanf?

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

[vwnc] Smalltalk equivalent for sscanf?

Rick Flower
I've got a phone number that will be brought in via Seaside and can be  
in
the following format (nnn) xxx-yyyy where everything but the parens are
numbers.  I want to convert it back to a fixed point value (e.g.  
nnnxxxyyyy).

Unfortunately, I didn't see any obvious way to do this aside from  
parsing
the string.. Is there something similar to sscanf() for Smalltalk that  
I can
pass a format string to and have it do the dirty work?  Thanks!

-- Rick

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Smalltalk equivalent for sscanf?

Rick Flower
Nevermind.. Found what I was looking for..

-- Rick
On Sep 8, 2008, at 10:59 PM, Richard E. Flower wrote:

> I've got a phone number that will be brought in via Seaside and can be
> in
> the following format (nnn) xxx-yyyy where everything but the parens  
> are
> numbers.  I want to convert it back to a fixed point value (e.g.
> nnnxxxyyyy).
>
> Unfortunately, I didn't see any obvious way to do this aside from
> parsing
> the string.. Is there something similar to sscanf() for Smalltalk that
> I can
> pass a format string to and have it do the dirty work?  Thanks!
>
> -- Rick
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Smalltalk equivalent for sscanf?

Andre Schnoor
In reply to this post by Rick Flower

> I've got a phone number that will be brought in via Seaside and can be
> in the following format (nnn) xxx-yyyy where everything but the  
> parens are
> numbers.  I want to convert it back to a fixed point value (e.g.
> nnnxxxyyyy).
>
> Unfortunately, I didn't see any obvious way to do this aside from
> parsing the string.. Is there something similar to sscanf() for
> Smalltalk that I can pass a format string to and have it do the
> dirty work?  Thanks!

Rick, this will filter all non-digits:

numbers := myMixedString select: [ :char | char isDigit ].

If you need to separate the different parts of a phone number, you  
will however need to parse it. The Package/Parcel "Regex11" has some  
nice tools for this. See class comments of RxParser.

Andre

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc