View previous topic :: View next topic
|
Author |
Message |
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi,
Can anyone please tell me how we can check in rexx if a string is having only alphanumeric characters and underscores?
Example.
The following strings are valid
Code: |
AAAA
1AAA_A
_AAAA
A12_1
AA1_ |
The following strings are NOT valid
Code: |
AAAA
A@AA_A
_AA%AA
A12_1
A?A1_ |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
First in each is AAAA, so is it valid or not? Also A12_1 appears in both. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
if it is under ISREDIT MACRO, then use find/search command
if it is a REXX SCRIPT being executed and not an ISREDIT MACRO
you could do the same thing I did and look for commands like POS.
but as Bill said,
your example sucks. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
read the manual and meditate on the VERIFY builtin |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
I am sorry...
NOT VAILD are
Code: |
A@AA_A
_AA%AA
A?A1_
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you search the forum, you'll even find a working example of VERIFY from very recently. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Thanks enrico... VERIFY worked for me.... |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Also try DATATYPE |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi Nic,
I tried datatype but was was stuck in how to check it any of the other characters are present apart from valid ones (0-9,A-Z,_).
DATATYPE provides only a few options
either BooleanNo = DATATYPE( String , Option )
or CHARorNUM = DATATYPE( String )
Options:
A - Alphanumeric (A-Z,a-z,0-9) N - Valid Number
B - Binary only (0,1) U - Uppercase only (A-Z)
L - Lower case only(a-z) W - Whole Number
M -Mixed case (A-Z, a-z) X - Hexadecimal (0-9, A-E)
S - Valid REXX Symbol(A-Z,a-z, 0-9 ! ? _ .) |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You could change all occurences of the underscore to an alpha, then do the alphanumeric. As long as you don't use the changed data for anything but the test.
I think the verify provides a more easily understood solution. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Quote: |
You could change all occurences of the underscore to an alpha |
Sometime back we had a problem of getting alpha symbol "α" in a mainframe report, but was unable to do it, can't find the EBCDIC code for it :S . How to get this character "α" in mainframe screen?
Maybe a bit too off-topic..
Edited: Looks like the alpha symbol above, is getting translated. Alpha, the one on Start->All programs->Accessories->System Tools->Character Map->Search for->alpha |
|
Back to top |
|
|
|