Page 1 of 1

String Compare

Posted: Mon Jun 02, 2008 10:20 pm
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

Posted: Mon Jun 02, 2008 10:25 pm
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.

Posted: Mon Jun 02, 2008 10:51 pm
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

Posted: Tue Jun 03, 2008 12:05 am
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.