Class: ByteString
Description
This method locates the next position of a bytestring within the source string.
Syntax
ByteString.find(ByteString find,Number start)
Parameters
find
|
If absent or empty, the method returns the implied value of the start parameter (i.e., the empty string is located immediately before the start position). |
start |
The byte position at which to start the search (1 denotes the first character, etc.). If you specify a value less than 1, the method uses 1. The default is 1. |
Returns
A number that specifies the position of the byte that follows the find byte string. If the byte string is not found, zero is returned.
When Became Available
Profile V7.0
Example
type String STR = "Knäckebröd"
type ByteString BST = STR.toByteString()
type ByteString BYT = 195.byte() // single byte: 195
type String CHR = 195.char() // two bytes (!): 195, 131
type String UMLA = 228.char() // ä, two bytes as well
//
// Find the BYT occurring in both two-byte chars
type Number NUM1 = BST.find( BYT) // NUM1 = 4
type Number NUM2 = BST.find( BYT, 6) // NUM2 = 11
//
// Even if CHR is interpreted as ByteString, it remains a two-byte sequence
// that does not occur in BST
type Number NUM0 = BST.find( {ByteString}CHR) // NUM0 = 0
//
// If UMLA is interpreted as ByteString, it will be found, and it returns
// the byte (!) position that follows the ä
type Number NUM3 = BST.find( {ByteString}UMLA) // NUM3 = 5