Difference between revisions of "Substr"
From SDU
(New page: Overloaded method to return s string within a string string substr(string str, int start, int finish) string substr(string str, int start) // reads to the end of the string for finish Ca...) |
m (Reverted edits by Agegeleruvy (Talk); changed back to last version by Nikolajus) |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| − | Overloaded method to return | + | __NOTOC__ |
| + | [[Category:Customizations]] | ||
| + | [[Category:r6]] | ||
| + | [[Category:r11]] | ||
| + | [[Category:Spel Code]] | ||
| + | {{Global Header}} | ||
| + | {{Global Announcement}} | ||
| + | |||
| + | Overloaded method to return a string within a string | ||
| + | |||
| + | string substr(string str, int start, int length) | ||
| + | |||
| + | string substr(string str, int start) // reads to the end of the string for finish | ||
| − | |||
| − | |||
Can be used in conjuction with sindex to retrieve start index. | Can be used in conjuction with sindex to retrieve start index. | ||
| Line 9: | Line 19: | ||
string myString; | string myString; | ||
| + | |||
string otherString; | string otherString; | ||
otherString = "this is a string"; | otherString = "this is a string"; | ||
| + | |||
myString = substr(otherString,sindex(otherString,"a")); | myString = substr(otherString,sindex(otherString,"a")); | ||
| − | // myString = "a string" | + | |
| + | // myString == "a string" | ||
| + | |||
| + | myString = substr(otherString,sindex(otherString,"is",4)); | ||
| + | |||
| + | // myString == "is a" | ||
Latest revision as of 05:22, 30 November 2010
To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.
To discuss or ask questions about this article, select the discussion tab above.
Overloaded method to return a string within a string
string substr(string str, int start, int length)
string substr(string str, int start) // reads to the end of the string for finish
Can be used in conjuction with sindex to retrieve start index.
eg.
string myString;
string otherString;
otherString = "this is a string";
myString = substr(otherString,sindex(otherString,"a"));
// myString == "a string"
myString = substr(otherString,sindex(otherString,"is",4));
// myString == "is a"