Difference between revisions of "Substr"
From SDU
Agegeleruvy (Talk | contribs) |
m (Reverted edits by Agegeleruvy (Talk); changed back to last version by Nikolajus) |
||
| Line 1: | Line 1: | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
__NOTOC__ | __NOTOC__ | ||
[[Category:Customizations]] | [[Category:Customizations]] | ||
| Line 30: | Line 22: | ||
string otherString; | string otherString; | ||
| − | otherString = | + | otherString = "this is a string"; |
| − | myString = substr(otherString,sindex(otherString, | + | myString = substr(otherString,sindex(otherString,"a")); |
| − | // myString == | + | // myString == "a string" |
| − | myString = substr(otherString,sindex(otherString, | + | myString = substr(otherString,sindex(otherString,"is",4)); |
| − | // myString == | + | // 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"