;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfStrCamelCaseContract (strString) strString = StrTrim (strString) If strString == "" Then Return strString strOut = "" intCount = ItemCount (strString, " ") For intItem = 1 To intCount strItem = ItemExtract (intItem, strString, " ") If strItem == "" Then Continue strOut = strOut : StrUpper (StrSub (strItem, 1, 1)) : StrSub (strItem, 2, -1) Next Return strOut ;.......................................................................................................................................... ; This UDF "udfStrCamelCaseContract" contracts the words from a given string by deleting the spaces between the words. ; Additionally the first character of each word is set to uppercase. ; The resulting string is a so called "CamelCase" string. ; ; Example ; In : This string will be contracted to a so called camel case string. ; Out: ThisStringWillBeContractedToASoCalledCamelCaseString. ; ; Detlev Dalitz.20110113. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfStrCamelCaseSpread (strString) strString = StrTrim (strString) If strString == "" Then Return strString objRegExp = ObjectCreate ("VBScript.RegExp") objRegExp.Global = @TRUE objRegExp.MultiLine = @FALSE objRegExp.IgnoreCase = @FALSE objRegExp.Pattern = "([a-z0-9])([A-Z0-9])" Return "" : objRegExp.Replace(strString, "$1 $2") ;.......................................................................................................................................... ; This UDF "udfStrCamelCaseSpread" spreads a so called "CamelCase" string into words ; by inserting a space character before any capital letter or digit. ; ; Example ; In : ThisStringIsASoCalledCamelCaseStringAndWillBeSpreadIntoSeparateWords. ; Out: This String Is A So Called Camel Case String And Will Be Spread Into Separate Words. ; ; Detlev Dalitz.20110113. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. strText = " This is the 2nd song from D.D.'s first album 30 years ago. " strCC_Contract = udfStrCamelCaseContract (strText) ; "ThisIsThe2ndSongFromD.D.'sFirstAlbum30YearsAgo." strCC_Spread = udfStrCamelCaseSpread (strCC_Contract) ; "This Is The 2nd Song From D.D.'s First Album 30 Years Ago." :CANCEL Exit