Gentee Programming Language > Documentation > Libraries Download documentation

String search

The spattern type is used to search through the string for another string. Before search start-up, call the spattern.init method in order to initialize the search pattern.
 
uint spattern.search(
      str   src,
      uint   offset
)

Parameters

srcString where the specified string will be searched (search pattern).
offsetOffset where the search must be started or proceeded.

Return value

The offset of the found fragment. If the offset is equal to string size,no fragment is found.

spattern sp
str src = "This is a test string."
...
sp.init( "test", 0 )
if sp.search( src, 0 ) < *src 
{
   print("The pattern has been found in the source string!\n")
}

See also

    Strings


 Copyright © 2004-2006 Gentee Inc. All rights reserved.