Page 1 of 1

check special characters

Posted: Mon Feb 21, 2005 3:13 am
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

Posted: Mon Feb 21, 2005 3:26 am
by Sainath.Srinivasan
Use char() function to find whether it is in permitted list and use a NOT option.

Re: check special characters

Posted: Mon Feb 21, 2005 3:37 am
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.

Posted: Mon Feb 21, 2005 8:42 am
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

Posted: Mon Feb 21, 2005 3:07 pm
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.