Im searching for bad chars in a DB. I dont want to write a really large LS agent that slowely crawls through each file and each title field looking for a range of Chars.
I was given a list of bad chars 146=Æ, 248=°, 9=TAB, 10=break, 13=break, etc. Need to just filter those out so DB2 doesn’t vomit when passed data over a notrix job.
What I was doing was a huge @Contains formula like this:
SELECT @Contains(Title;@Char(9):@Char(10):@Char(13):@Char(146):@Char(147):@Char(148):@Char(150):@Char(151):@Char(174):@Char(248))
For a view selection. Nice and slow
Not a view anyone will look at, just used by an agent to clean up the data. But the thing is I want to just grab any char thats outside of the range 31-128. Can I pass it that or would I have to concatonate every single char???
Subject: Would an @ReplaceSubstring do the trick for you?
Couldn’t you run an agent on the fields in question for all docs with code similar to this? First you make a list of “BadCharacters” and then you set the field to itself removing all of those “BadCharacters”
BadCharacters := “@”:“|”:@Char(9):“*”:@Char(10);
FIELD ABC := @Trim(@ReplaceSubstring(ABC; BadCharacters; “”))
Hope this helps, Quin
Subject: RE: Would an @ReplaceSubstring do the trick for you?
Was sort of doing something like that. But that has the same problem as the @Contains as well as another problem.
I still can’t just go by the list of like 10 bad chars that the DB2 guys have found so far. There may be more. So I need to search for all chars 0-30 and 129-255.
The second problem is Im not allowed to just remove the bad chars and replace them with nothing or a space etc. I have to find a doc with a bad title, then re-read the title from a database that has been cleaned (All titles were just entered in by hand).
Subject: RE: Try @Matches
Can you do@Matches(Title;+{@Char(129)-@Char(255)})
?
Subject: RE: Try @Matches
Eh, am I doing this wrong?
I tried:
SELECT @Matches(Title;+{ƒ-ÿ})
And the view kicked back nothing. And there is a document with Title that has a char between those two (131 - 255).
Can you not just put any range of Chars you want in @Matches?
Subject: RE: Try @Matches
Well I got it to half way work =\
SELECT @IsAvailable(Title) & !(Title = “”) & !@Matches(Title;“+{ -~}”)
So I want to return any doc that has a field Title that is not made up of characters that are only between " " and “~”. It did return a few docs that had char(150) “–” which is not the standard dash, another bad char when copy and pasted from Word.
But it didnt grab the doc that has a “°” in it =( char(176) or char(248) depending on what you are reading from.
Does @Matches not work on certain char ranges?
Subject: RE: Try @Matches
For me, @Prompt([Ok]; “”; @Text(@Matches(“°”; “+{-~}”))) displays 0, so I don’t know why your selection isn’t working.
Incidentally, you don’t have to test the field three times. Title != “” & @Matches… shoule work.
Subject: @Contains, can you give it a range?
Don’t know if this will work but what about the following.
SELECT @Ascii(Title;[ALLINRANGE]) = “”
if the Title string contains a character that is not in the range 32 to 127 then @Ascii will return a null string. Otherwise @Ascii will return the string converted to ASCII.