"splitstring" Snippets


String splitting

Methods for splitting strings to arrays
Created: 1465312162
View "String splitting"
<mvt:assign name="g.string" value="'one|two|three|four|five|six'" /> <h3>Split String mvt:do</h3> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Get Token</h3> <p>Doesn't support multi-character splitting, a little harder to read in my opinion</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.nl" value="'|'" /> <mvt:assign name="l.count" value="1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> <mvt:while expr="NOT ISNULL l.token"> <mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" /> <mvt:assign name="l.count" value="l.count + 1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> </mvt:while> <mvt:foreach iterator="row" array="my_array"> &mvt:row;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>New MivaScript Split String</h3> <p>Probably easiest to use</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.array" value="miva_splitstring(g.string, '|', g.array, NULL)" /> <mvt:foreach iterator="row" array="my_array"> &mvt:row;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds.
 

Basket #16315

Methods for splitting strings to arrays
Created: 1461119732
View "Basket #16315"
<mvt:assign name="g.string" value="'one|two|three|four|five|six'" /> <h3>Split String mvt:do</h3> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> <br> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach>
 

Snippet: 1460047868 - v1

Methods for splitting strings to arrays
Created: 1460047868
View "Snippet: 1460047868 - v1"
<mvt:assign name="g.string" value="'one|||two|||three|||four|||five|||six'" /> <h3>Split String mvt:do</h3> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|||', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|||',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Get Token</h3> <p>Doesn't support multi-character splitting, a little harder to read in my opinion</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.nl" value="'|||'" /> <mvt:assign name="l.count" value="1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> <mvt:while expr="NOT ISNULL l.token"> <mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" /> <mvt:assign name="l.count" value="l.count + 1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> </mvt:while> <mvt:foreach iterator="row" array="my_array"> &mvt:row;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds.
 

String splitting

Methods for splitting strings to arrays
Created: 1460047755
View "String splitting"
<mvt:assign name="g.string" value="'one|two|three|four|five|six'" /> <h3>Split String mvt:do</h3> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds. <hr> <h3>Get Token</h3> <p>Doesn't support multi-character splitting, a little harder to read in my opinion</p> <mvt:assign name="g.startTime" value="s.dyn_tm_usec" /> <mvt:assign name="g.nl" value="'|'" /> <mvt:assign name="l.count" value="1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> <mvt:while expr="NOT ISNULL l.token"> <mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" /> <mvt:assign name="l.count" value="l.count + 1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> </mvt:while> <mvt:foreach iterator="row" array="my_array"> &mvt:row;</br> </mvt:foreach> </br>Completed in <mvt:eval expr="s.dyn_tm_usec - g.startTime" /> milliseconds.
 

String splitting

Methods for splitting strings to arrays
Created: 1460041211
View "String splitting"
<mvt:assign name="g.string" value="'one|two|three|four|five|six'" /> <h3>Split String mvt:do</h3> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> <hr> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach> <hr> <h3>Get Token</h3> <p>Doesn't support multi-character splitting, a little harder to read in my opinion</p> <mvt:assign name="g.nl" value="'|'" /> <mvt:assign name="l.count" value="1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> <mvt:while expr="NOT ISNULL l.token"> <mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" /> <mvt:assign name="l.count" value="l.count + 1" /> <mvt:assign name="l.token" value="gettoken(g.string, g.nl , l.count)" /> </mvt:while> <mvt:foreach iterator="row" array="my_array"> &mvt:row;</br> </mvt:foreach>
 

String splitting

Methods for splitting strings to arrays
Created: 1460040170
View "String splitting"
<mvt:assign name="g.string" value="'one|two|three|four|five|six'" /> <h3>Split String mvt:do</h3> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> <br> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach>
 

Basket #8353

Methods for splitting strings to arrays
Created: 1449263140
View "Basket #8353"
<mvt:assign name="g.test" value="'one two three four five'" /> <mvt:assign name="g.test2" value="'uno dos tres quatro cinco'" /> <mvt:assign name="g.null" value="miva_splitstring( g.test, ' ', g.array, NULL )" /> <mvt:assign name="g.null" value="miva_splitstring( g.test2, ' ', g.array2, NULL )" /> <mvt:assign name="g.output" value="g.array[1] $ '-' $ g.array[2] $ '-' $ g.array[3] $ '-' $ g.array2[1] $ '-' $ g.array2[2] $ '-' $ g.array2[3]" /> &mvt:global:output;