## Identifying Series of numbers in a string

15 pts.
Tags:
AS400 RPGLE
RPG/400
RPGLE
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

Thanks. We'll let you know when a new response is added.

## Discuss This Question: 7 Replies

Thanks. We'll let you know when a new response is added.
• 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
report
• 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
report
• 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
report
• 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
report
• (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
report
• And, can a string have more than one series? Tom
report
• %CHECK() is your friend. Use it to determine the start of your sequence(s). From there you can determine what to do.