check special characters

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kamesh
Participant
Posts: 72
Joined: Tue May 27, 2003 1:47 am

check special characters

Post by kamesh »

I want to check some spcial characters in a column.. like i want to check
characters not in ([a-z],[A-Z],[0-9],!<@,#,$<%,^,&,*,(,),>,<,?,,.,/)like this..
pls anyone help me out how to do this using datastage

Thanks
kamesh
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Use char() function to find whether it is in permitted list and use a NOT option.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: check special characters

Post by ArndW »

kamesh wrote:...characters not in ([a-z],[A-Z],[0-9],!<@,#,$<%,^,&,*,(,),>,<,?,,.,/)
DataStage server offers a number of builtin functions for this kind of comparison. One of the more powerful functions is the MATCH[es] one documented in the BASIC pdf on page 6-382 ff. This does string pattern matching; there are a number of ICONV/OCONV functions which will do string conversion for you as well, i.e. "OCONV(MyString,"MCP") to remove non-printable characters.
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

hi,

Well this piece of code will tell you if a string contains a non numeric and a non alphabetic character.

If Iconv(Oconv(Arg1,"MC/N"),"MC/A") matches "~0A" :char(253):"~0N" Then
Ans='String contains special characters :' :Iconv(Oconv(Arg1,"MC/N"),"MC/A")
End Else
Ans='No String Does Not contain Any Special Character'
End

-shantanu
Shantanu Choudhary
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The best function to use is Index() or Convert().

Code: Select all

Index(searchcharacters, mycharacter, n) 
searches for the nth occurrence of mycharacter in searchcharacters, returning 0 if not found.

Code: Select all

Convert(searchcharacters, "", mystring) 
removes all of the searchcharacters from mystring so that, if there is anything left, it wasn't a character in searchcharacters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply