|
Hi,
> I was wondering how I could strip any non numberic characters from a set
> of numbers submitted via a html form. For example (504) 555-5555 would
> be 5045555555 or 504-555-5555 would be 5045555555 Like %trim does with
> spaces is there something to deal with non-numberics?
Why not just write a quick routine to do it? For example, you could do
something like this:
H DFTACTGRP(*NO)
D IncludeOnly PR 30A varying
D Input 60A varying const
D Chars 20A varying const
D test s 10A
c eval test = IncludeOnly('(504) 555-1234'
c : '01234567890')
c dsply test
c eval *inlr = *on
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* IncludeOnly(): Strip characters from parameter one that aren't
* in parameter two.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P IncludeOnly B export
D IncludeOnly PI 30A varying
D Input 60A varying const
D Chars 20A varying const
D RetVal s 100A varying
D x s 10I 0
c eval %len(RetVal) = 0
c for x = 1 to %len(Input)
c if %check( Chars: %subst(Input:X:1) ) = 0
c eval RetVal = RetVal + %subst(Input:X:1)
c endif
c endfor
c return RetVal
P E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.