Difference between revisions of "Tutorial: String Variables 8"
Jump to navigation
Jump to search
imported>Odessa (Created page with "This is the eighth article in a tutorial on string variables. ==Measuring and Searching== Sv_Length returns the length of a string va...") |
imported>Odessa |
||
Line 1: | Line 1: | ||
This is the eighth article in a [[Tutorial: String Variables|tutorial]] on [[string variables]]. | This is the eighth article in a [[Tutorial: String Variables|tutorial series]] on [[string variables]]. | ||
==Measuring and Searching== | ==Measuring and Searching== | ||
Line 37: | Line 37: | ||
==External Links== | ==External Links== | ||
*[http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ The original text of this page was adapted with permission from this source] | *[http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ The original text of this page was adapted with permission from this source] | ||
[[Category:String Variables]] |
Revision as of 11:53, 27 June 2014
This is the eighth article in a tutorial series on string variables.
Measuring and Searching
Sv_Length returns the length of a string var's string:
let iSomeInt := sv_length sv_stringvar
Since the start position is always indexed at 0, the end position will always be (sv_length sv_stringvar) - 1.
Sv_Find finds the first occurrence of a substring in a string, and returns the position as an int:
let iSomeInt := sv_Find "substring" FormatSpecifierVars SourceStringVar StartPositionInt SearchLengthFromStartPosInt CaseSensitiveSearchBool ; leave out the parameters if you don't need them let sv_stringvar := "This is example 3" let iSomeInt1 := sv_Find "example %.0f" someInt2 sv_stringvar ; --> will return 8 if someInt2 is 3
Sv_Count returns just how many instances of a substring a string contains:
let sv_stringvar := "Ain't no sunshine when she's gone. And she's always gone too long." let iSomeInt := sv_Count "gone" sv_stringvar ; --> returns 2
Tutorial part 9: Replacing and Reassembling