FUNCTIONS CORE

BeforAtNum()

Extract the part of a string before the last occurrence of a search string

Syntax

Signature
BeforAtNum( cSearch, cString, [nCount], [nSkipChars] ) --> cResult

Arguments

cSearch

cString

nCount

nSkipChars

Example

BeforAtNum.prg
PROCEDURE Main()

   LOCAL cPath := "C:\xDev\tests\BeforAtNum.prg"

   Check( 'BeforAtNum( "\", cPath )                 ', BeforAtNum( "\", cPath ), "C:\xDev\tests" )
   Check( 'BeforAtNum( ".", "archive.tar.gz" )      ', BeforAtNum( ".", "archive.tar.gz" ), "archive.tar" )
   Check( 'BeforAtNum( ".", "archive.tar.gz", 1 )   ', BeforAtNum( ".", "archive.tar.gz", 1 ), "archive" )
   Check( 'BeforAtNum( "/", "archive.tar.gz" )      ', BeforAtNum( "/", "archive.tar.gz" ), "" )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

BeforAtNum( "\", cPath )                 OK
BeforAtNum( ".", "archive.tar.gz" )      OK
BeforAtNum( ".", "archive.tar.gz", 1 )   OK
BeforAtNum( "/", "archive.tar.gz" )      OK