Hi,
I have a requirement to match a description field to be in title case. For example, this would be a valid description:"Removal of Motor". However, these would not be a valid description "removal of motor", or "REMOVAL OF MOTOR". We can take care of when each word needs to start with a capital letter, but how do we make sure that words like 'of, 'and' etc stay in lower case ? Also there may be some abbreviations in the text which strictly need to be in capital case like "Removal of Motor ISO". Any ideas on how I can do this ?
Thanks,
check for data consistancy
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The usual solution to this is a custom Routine that uses a set of exception words, perhaps stored in a table (or hashed file). The following pseudo code explains the algorithm.
Code: Select all
Ans = ""
LOOP
Get Next Word
UNTIL No Word Found
Lookup Word In Exceptions
IF (In Exceptions)
THEN
NewWord = Word
ELSE
NewWord = Oconv(Word, "MCT") ; * Title Case
END IF
Ans := " " : NewWord
REPEAT
Ans = Ans[2,Len(Ans)-1] ; * remove leading space
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.