Search the Community
Showing results for tags 'sentence case'.
-
This is a spin-off of >Seeker's function which i rewrote and tried to optimize for doing only sentence casing and for better Unicode handling. Haven't done a lot of testing with it, but it seems to work well so far. #include-once ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SentenceCase ; Description ...: Capitalize the first letter of sentences. ; Syntax ........: _SentenceCase(Byref $sString) ; Parameters ....: $sString: [in/out] A string value. ; Return values .: Success: A string is returned. ; Failure: Sets @error = 1 and returns 0. ; Author ........: iCode ; Modified ......: 30-MAR-2015 ; Remarks .......: ; Related .......: http://www.autoitscript.com/forum/topic/147086-udf-for-title-case-initial-caps-and-sentence-case/ ; Link ..........: http://www.autoitscript.com/forum/topic/169290-sentence-case-capitalize-first-letter-of-sentences/ ; Example .......: No ; =============================================================================================================================== Func _SentenceCase(ByRef $sString) Local $aStr = StringRegExp($sString, "(*UCP)(?s)[[:alpha:]].+?(?:[.?!:;]|\z)\s*|[^[:alpha:]]+", 3) If @error Then Return SetError(1, 0, 0) Local $sChar, $sRet = "" For $i = 0 To UBound($aStr) - 1 If StringRegExp($aStr[$i], "(*UCP)(?s)^[[:alpha:]]+.*?[.?!:;]") Then $sChar = StringLeft($aStr[$i], 1) If StringIsLower($sChar) Then $aStr[$i] = StringUpper($sChar) & StringTrimLeft($aStr[$i], 1) EndIf EndIf $sRet &= $aStr[$i] Next Return $sRet EndFunc CHANGE LOG: 28-MAR-2015 - initial version 30-MAR-2015 - added more sentence terminition characters ( ; : ) - should probably get these from a variable?
- 2 replies
-
- case
- sentence case
-
(and 1 more)
Tagged with: