Difference between revisions of "Substr"

From SDU
Jump to: navigation, search
m (Reverted edits by Agegeleruvy (Talk); changed back to last version by Nikolajus)
 
Line 1: Line 1:
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://aduratutuz.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
 
----
 
=[http://aduratutuz.co.cc CLICK HERE]=
 
----
 
</div>
 
 
__NOTOC__
 
__NOTOC__
 
[[Category:Customizations]]
 
[[Category:Customizations]]
Line 30: Line 22:
 
string otherString;
 
string otherString;
  
otherString = &quot;this is a string&quot;;
+
otherString = "this is a string";
  
myString = substr(otherString,sindex(otherString,&quot;a&quot;));
+
myString = substr(otherString,sindex(otherString,"a"));
  
// myString == &quot;a string&quot;
+
// myString == "a string"
  
myString = substr(otherString,sindex(otherString,&quot;is&quot;,4));
+
myString = substr(otherString,sindex(otherString,"is",4));
  
// myString == &quot;is a&quot;
+
// 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.

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"