xHarbour Reference Documentation > Function Reference |
Locates the position of a substring within a character string.
AtSkipStrings(( <cSearch>, <cString> ) --> nPos
The function returns a numeric value which is the position in <cString> where <cSubString> is found. The return value is zero when <cSubString> is not found.
The function AtSkipStrings() searches the string <cString> from left to right for the character string <cSearch>. It works similar to the At() function, but skips all quoted parts of <cString>. A quoted part is recognized when it is enclosed in a pair of single or double quotes, or within opening and closing square brackets.
See also: | At(), HB_RegEx(), IN, Left(), RAt(), Right(), StrTran(), SubStr() |
Category: | Character functions , xHarbour extensions |
Source: | rtl\at.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example compares results of AtSkipStrings() with At() PROCEDURE Main LOCAL cString1 := '"abc"12abc' LOCAL cString2 := "123;'xHarbour;compiler';200702" LOCAL nPos ? At( "abc", cString1 ) // result: 2 ? AtSkipSTrings( "abc", cString1 ) // result: 8 cString1 := cString2 DO WHILE .NOT. Empty( cString1 ) nPos := At( ";", cString1 ) IF nPos > 0 ? SubStr( cString1, 1, nPos-1 ) cString1 := SubStr( cString1, nPos+1 ) ELSE ? cString1 cString1 := "" ENDIF ENDDO ** output // 123 // 'xHarbour // compiler' // 200702 DO WHILE .NOT. Empty( cString2 ) nPos := AtSkipSTrings( ";", cString2 ) IF nPos > 0 ? SubStr( cString2, 1, nPos-1 ) cString2 := SubStr( cString2, nPos+1 ) ELSE ? cString2 cString2 := "" ENDIF ENDDO ** output // 123 // 'xHarbour;compiler' // 200702 RETURN
http://www.xHarbour.com