I am using the code below to make a string have capitalization for the first letter in each word. I would like to take this a step further, and only capitalize all words that are not prepositions, or conjunctions (the, and, an, as, to) etc. Is this possible in classic ASP?
Convert this:
this is the best website on the web
To this:
This is the Best Website on the Web
I would think this is possible with RegEx, but I don't have a clue on where to start with that. Any help is appreciated.
queryForHTML = capCase(queryForHTML,true)
You could use a
HashSet(Of String)
to store those exceptional words. Then split by white-space to get all words in a string, check whether you need to upper- or lowercase the first letter and usestring.Join
to create a new string.Here is a method that does it:
Your sample input:
Edit: i'm not familiar with classic ASP, so i don't know if it helps.
There isn't anything built into classic ASP that is going to do this for you.
The only option I can think of is to build a dictionary of words that should not be capitalized and modify your code not to include those words.
This is my first idea. I'm sure you are able to improve that.
Output:
This is the Best Website on the Web
Edit: You can use CSS to capitalize the words as well (Note this will capitalize every word in lower case)