|
CX Framework
Cross-platform C utility framework
|
Functions | |
| int32 | strFind (strref s, int32 start, strref find) |
| int32 | strFindR (strref s, int32 end, strref find) |
Functions for finding substrings within strings.
| int32 strFind | ( | strref | s, |
| int32 | start, | ||
| strref | find | ||
| ) |
Finds the first occurrence of a substring (forward search)
Searches for the first occurrence of the substring 'find' in string 's', starting at the specified position. The search proceeds forward toward the end of the string.
Negative start positions are relative to the end of the string, allowing searches from a position near the end. If the substring is not found, -1 is returned.
| s | String to search within |
| start | Starting position for search (negative = from end) |
| find | Substring to search for |
Example:
| int32 strFindR | ( | strref | s, |
| int32 | end, | ||
| strref | find | ||
| ) |
Finds the last occurrence of a substring (reverse search)
Searches for the last occurrence of the substring 'find' in string 's', searching backward from the specified end position. This is useful for finding the rightmost match or searching within a specific range.
The end position can be:
If the substring is not found, -1 is returned.
| s | String to search within |
| end | Ending position for search (0/strEnd = string end, negative = from end) |
| find | Substring to search for |
Example: