Difference between revisions of "Sv Find"
Added notes
imported>AndalayBay m (Added sentence about return value when substring not found.) |
imported>QQuix (Added notes) |
||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
| origin = OBSE | | origin = OBSE | ||
| summary = Returns the index of the first occurrence of a substring within a string variable, starting at the specified position and only including occurrences contained completely within the range <nowiki>[</nowiki>''startPos'', ''startPos + searchLen''<nowiki>]</nowiki>. Returns -1 if the substring is not found in the string variable. Omit the arguments to search the entire string without regard to case. | | summary = Returns the index of the first occurrence of a substring within a string variable, starting at the specified position and only including occurrences contained completely within the range <nowiki>[</nowiki>''startPos'', ''startPos + searchLen''<nowiki>]</nowiki>. | ||
Returns -1 if the substring is not found in the string variable. | |||
Omit the arguments to search the entire string without regard to case. | |||
| name = sv_Find | | name = sv_Find | ||
| returnVal = index | | returnVal = index | ||
Line 29: | Line 33: | ||
}} | }} | ||
}} | }} | ||
__NOTOC__ | |||
==Notes== | |||
*The index within a string starts at 0. | |||
*This function expects a literal as the first parameter (format string). If you are using a string variable, precede it with a $. | |||
let Source := "abcdef" | |||
let Substring := "c" | |||
let i := sv_Find Substring Source ; returns -1 << wrong | |||
let i := sv_Find $Substring Source ; returns 2 | |||
let i := sv_Find "c" Source ; returns 2 | |||
==OBSE Format Specifiers== | |||
{{MessageFormatting}} | {{MessageFormatting}} | ||
{{OBSE Format Specifiers}} | {{OBSE Format Specifiers}} |