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
check special characters
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Re: check special characters
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.kamesh wrote:...characters not in ([a-z],[A-Z],[0-9],!<@,#,$<%,^,&,*,(,),>,<,?,,.,/)
-
- Charter Member
- Posts: 199
- Joined: Tue Jan 18, 2005 2:50 am
- Location: India
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The best function to use is Index() or Convert().
searches for the nth occurrence of mycharacter in searchcharacters, returning 0 if not found.
removes all of the searchcharacters from mystring so that, if there is anything left, it wasn't a character in searchcharacters.
Code: Select all
Index(searchcharacters, mycharacter, n)
Code: Select all
Convert(searchcharacters, "", mystring)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.