FUNCTIONS CORE

AfterAtNum()

Return the portion of a string after the nth occurrence of a substring

Syntax

Signature
AfterAtNum( cSearch, cString, [nOccurrence], [nIgnore] ) --> cRest

Arguments

cSearch

cString

nOccurrence

nIgnore

Example

AfterAtNum.prg
PROCEDURE Main()

   Check( 'AfterAtNum( ".", "archive.tar.gz" )    ', AfterAtNum( ".", "archive.tar.gz" ), "gz" )
   Check( 'AfterAtNum( ".", "archive.tar.gz", 1 ) ', AfterAtNum( ".", "archive.tar.gz", 1 ), "tar.gz" )
   Check( 'AfterAtNum( "@", "anna@example.com" )  ', AfterAtNum( "@", "anna@example.com" ), "example.com" )
   Check( 'AfterAtNum( "/", "archive.tar.gz" )    ', AfterAtNum( "/", "archive.tar.gz" ), "" )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

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

RETURN

Output

AfterAtNum( ".", "archive.tar.gz" )    OK
AfterAtNum( ".", "archive.tar.gz", 1 ) OK
AfterAtNum( "@", "anna@example.com" )  OK
AfterAtNum( "/", "archive.tar.gz" )    OK