String Compare

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
senthilt1
Participant
Posts: 134
Joined: Mon Nov 19, 2007 2:17 am

String Compare

Post by senthilt1 »

Hi Friends,

I want to check whether my input field should contain only the following character set ,

1. Alphabets a-z
2. Numbers 0-9
3. Spl Chars " !#$%&'`\"()*+,-.:;?<=>/@[\\]^_{|}~";

If the inp field have any other characters than the above mentioned list, then it should be replaced with " ". I tried wih String compare function(IBM 8), but i couldnt get the right output.

Please help me to resolve this simple query.

Thanks,

Senthil P
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Initialize a stage variable with a string containing every other character and another containing the number of spaces that there are characters in the first. Use a Convert() function to map from one to the other.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
senthilt1
Participant
Posts: 134
Joined: Mon Nov 19, 2007 2:17 am

Post by senthilt1 »

Thanks Ray,

I got your point. But I find difficult in getting the every other character apart from the allowed,

1. Alphabets a-z
2. Numbers 0-9
3. Spl Chars " !#$%&'`\"()*+,-.:;?<=>/@[\\]^_{|}~";

If i have to use convert funtion, I should know what all are the other characters that is to be replaced with " ", But I dont know what are those chars.

Would you please suggest any idea to this?

Thanks,
Senthil P
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Assuming ASCII or equivalent:
  • all characters whose code is below 32

    characters in the range "A" through "Z" (assuming you want to keep only lower case alphabetics)

    all characters whose code is above 128
You can be somewhat selective in the first and last of these if you know, for example, that Ctrl-J (Char(10)) will never occur in your data.
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