15 pts.
 Identifying Series of numbers in a string
Hi, 
I seek your help in designing a RPG /RPGLE program which will identify the series of numbers among the character string (like phone #s, Credit card number, etc..)
Ex: If String A  = 'ABCDSSS123456DDB7BB' My result field should only fetch '123456' and not '7'.  (in this example '7' is not among series). 
Can someone enlighten ?


Software/Hardware used:
RPG/400 , ILE
ASKED: February 10, 2012  10:06 PM
UPDATED: March 17, 2012  5:28 AM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. Michael Tidmarsh   11,380 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Phone numbers, credit card numbers and others are often entered with special characters like ’555-1234′. What controls are in place to limit what your program might run into?

Tom

 107,735 pts.

 

Sounds like you want to:
1. find the position of the first digit in the string
2, Then find the first non-digit
3. Then extract the substing bounded by those positions.
Hope this helps

 44,070 pts.

 

Also, how long can the “strings” be? If these are basic string values 100 or 200 bytes or so long, it might be very different from handling a 16MB XML document or something like that.

Tom

 107,735 pts.

 

Philip,
Thanks for your response. I will work towards your suggestion.

Tom,
In my case, I am limiting the user from entering sensitive data in comments / notes section. Hence we may get any thing !!!. But we are limiting the program to read series of numerals (a.ka credit card – 16 digits / ph number 10 digits) ..

Regards
Kannan

 15 pts.

 

(in this example ’7′ is not among series)

Does that simply mean that ’7′ is just a single digit, so it can be ignored?

And again, how long are the strings? A basic estimate to get an idea about efficient techniques is needed.

Tom

 107,735 pts.

 

And, can a string have more than one series?

Tom

 107,735 pts.

 

%CHECK() is your friend. Use it to determine the start of your sequence(s).

From there you can determine what to do.

 5,670 pts.