xHarbour Reference Documentation > Function Reference |
Counts a specified character from the left side of a string.
CountLeft( <cString>, [<xChar>] ) --> nCount
The function counts <xChar> at the beginning of <cString> and returns as soon as a different character is detected. The number of times the character <xChar> is found consecutively at the beginning of <cString> is returned as a numeric value.
See also: | CountRight(), LTrim() |
Category: | CT:String manipulation , Character functions |
Source: | ct\count.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example displays results of CountLeft() PROCEDURE Main LOCAL cString1 := " Hello World " LOCAL cString2 := "aaaaabbbbbcc" ? CountLeft( cString1 ) // result: 3 ? CountLeft( cString2, "a" ) // result: 5 RETURN
http://www.xHarbour.com