Text.IndexOf
From Xojo Documentation
Supported for all project types and targets.
Finds the position of other within the text. Returns the zero-based location of other within the text. If other is not found, returns -1.
Parameters
Value | Description |
---|---|
other | The text to find within the original text. |
compareOptions | (Optional) Comparison options. Use constant CompareCaseSensitive for case-sensitive comparisons. |
locale | (Optional) The locale to use for comparisons. By default an invariant locale (not dependent on the system settings) is used. |
Supported for all project types and targets.
Finds the position of other within the text beginning with startPosition. Returns the zero-based location of other within the text. If other is not found, returns -1.
Parameters
Value | Description |
---|---|
startPosition | The zero-based starting position to begin the search. |
other | The text to find within the original text. |
compareOptions | (Optional) Comparison options. Use constant CompareCaseSensitive for case-sensitive comparisons. |
locale | (Optional) The locale to use for comparisons. By default an invariant locale (not dependent on the system settings) is used. |
Notes
By default this performs a case-insensitive comparison. To do a case-sensitive comparison, supply the CompareCaseSensitive constant to the compareOptions parameter.
By default comparisons are done in an invariant locale (i.e. not dependent on the user's preferences). The locale parameter can be used to specify an explicit locale to do comparisons in.
Exceptions
- RuntimeException if the specified options are invalid.
- InvalidArgumentException if other is an empty Text value.
Sample Code
Find the position of the text "wood":
Find the position of "wood" beginning with position 10: