hb_RAt()

hb_RAt()

Searches for last occurrence a substring of a string.

Syntax

      hb_RAt( <cSearch>,  <cString>,  [<nStart>],  [<nEnd>]  ) --> nPos

Arguments

<cSearch> Substring to search for

<cString> Main string

<nStart> First position to search in cString, by default 1.

<nEnd> End position to search, by default cString length

Returns

hb_RAt() return the location of beginning position of last occurrence a substring of a string.

Description

This function searches for last occurrence a <cSearch> in <cString>. If the function is unable to find any occurrence of <cSearch> in <cString>, the return value is 0. 3rd and 4th parameters define inclusive range for 2nd parameter on which operation is performed. If 3rd and 4th parameters is not specified, then hb_RAt() is equal to RAt().

Examples

      LOCAL cString
      LOCAL cSearch
      LOCAL i,  y,  r,  nLen

      ? 'hb_RAt( "cde",  "abcdefgfedcba" ) = ',  ;
         hb_RAt( "cde",  "abcdefgfedcba" ) // -> 3

      cString := "acdefcdeedcb"
      cSearch := "cde"
      nLen := Len( cString )
      FOR y := 1 TO nLen
         FOR i := 1 TO nLen
            r := hb_RAt( cSearch,  cString,  y,  i )
            IF r != 0
            ? 'hb_RAt( "' + cSearch + '",  "' + cString + '",  ' + hb_ntos( y ) + ',  ' + hb_ntos( i ) + ' ) = ' + ;
               hb_ntos( r )
            ENDIF
         NEXT
      NEXT

Compliance

Clipper

Platforms

All(64K)

Files

Library is core

Seealso

hb_At(), SubStr(), Right(), RAt()

3 responses to “hb_RAt()

  1. Pingback: Harbour All Functions – H | Viva Clipper !

  2. Pingback: Harbour String Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.