"string" Snippets


Basket #55979

capitalize a string
Created: 1503004065
View "Basket #55979"
<mvt:assign name="g.str" value="'caleb'" /> <mvt:assign name="g.capitalize" value="toupper(g.str)" /> &mvt:global:capitalize;
 
View "Get Everything after a String"
<mvt:assign name="g.string" value="'something.com/goes-here.html'" /> <mvt:assign name="g.split" value="'.com'" /> <mvt:assign name="g.after_index" value="(g.split CIN g.string) + len(g.split)" /> <mvt:assign name="g.after" value="substring( g.string, g.after_index , len(g.string) )" /> &mvte:global:after;
 

Basket #52503

Methods for splitting strings to arrays
Created: 1501196880
View "Basket #52503"
<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 #51494

Methods for splitting strings to arrays
Created: 1500068671
View "Basket #51494"
<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> <mvt:assign name="g.randomNumber" value="random(99)" /> &mvt:global:randomNumber;
 
View "Basket #47367"
<mvt:assign name="g.cc_num_dirty" value="'44a44-5555/3333A1111-adasdsadasdas!'" /> <mvt:while expr="l.character_counter LT len(g.cc_num_dirty)"> <mvt:assign name="l.character_counter" value="l.character_counter + 1" /> <mvt:assign name="l.character" value="substring_var( g.cc_num_dirty, l.character_counter, 1 )"/> <mvt:if expr="isdigit(l.character)"> <mvt:if expr="l.digit_counter GT 0 AND l.digit_counter MOD 4 EQ 0"> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ '-'" /> </mvt:if> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ l.character" /> <mvt:assign name="l.digit_counter" value="l.digit_counter + 1" /> </mvt:if> </mvt:while> abc &mvte:global:cc_num_clean;
 

Basket #29601

capitalize a string
Created: 1485552377
View "Basket #29601"
<mvt:assign name="g.str" value="'chris dye'" /> <mvt:assign name="g.capitalize" value="toupper(substring(g.str,0,1)) $ subString(g.str,2,len(g.str))" /> &mvt:global:capitalize;
 

Basket #25606

 string
[Video Tutorial](http://www.miva.com/videos/web_developers/structures) Structures are a lot like arrays.
Created: 1476732650
View "Basket #25606"
<mvt:assign name="l.settings:example:states[1]:abbr" value="'CA'" /> <mvt:assign name="l.settings:example:states[1]:name" value="'California'" /> <mvt:assign name="l.settings:example:states[2]:abbr" value="'FL'" /> <mvt:assign name="l.settings:example:states[2]:name" value="'Florida'" /> <mvt:foreach iterator="state" array="example:states"> <mvt:assign name="l.length" value="len(l.settings:state:name)" /> &mvt:state:abbr; - &mvt:state:name;<br> </mvt:foreach> l.length=<mvt:eval expr="l.length" />
 

Basket #18886

Grab the 3 letter extension off of an image file. Could be improved to look for last ',' and grab all after in case of variations like '.jpeg'.
Created: 1473454796
View "Basket #18886"
<mvt:assign name="g.url" value="'http://dev.mcrmedical.com/mm5/graphics/00000001/fak28-MCR-first-aid-kit-front.jpeg'" /> <mvt:assign name="g.extension" value="substring(g.url,(len(g.url)-3),4)" /> &mvt:global:extension;
 

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.
 

string scrubber

Delete all characters from string except characters that you define.
Created: 1462377050
View "string scrubber"
<mvt:comment>define your allowed characters</mvt:comment> <mvt:assign name="g.allowed" value="'abcdefghijklmnopqrstuvwxyz'" /> <mvt:comment>the string to scrub</mvt:comment> <mvt:assign name="g.string" value="'Test123-!hello'" /> <mvt:assign name="g.counter" value="1" /> <mvt:comment>for each letter in string</mvt:comment> <mvt:while expr="g.counter LE len(g.string)"> <mvt:comment>if this letter is contained in allowed, increment</mvt:comment> <mvt:if expr="substring(g.string, g.counter, 1) CIN g.allowed"> <mvt:assign name="g.counter" value="g.counter+1" /> <mvt:else> <mvt:comment>if letter is not in allowed, delete it, we don't need to increment because we just made the string 1 shorter</mvt:comment> <mvt:assign name="g.string" value="substring(g.string, 1, g.counter-1 ) $ substring(g.string, g.counter+1, (len(g.string)+1)-g.counter)" /> </mvt:if> </mvt:while> &mvt:global:string;
 

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>
 

image extension

Grab the 3 letter extension off of an image file. Could be improved to look for last ',' and grab all after in case of variations like '.jpeg'.
Created: 1459875237
View "image extension"
<mvt:assign name="g.url" value="'http://dev.mcrmedical.com/mm5/graphics/00000001/fak28-MCR-first-aid-kit-front.jpg'" /> <mvt:assign name="g.extension" value="substring(g.url,(len(g.url)-3),4)" /> &mvt:global:extension;
 

image extension

Grab the 3 letter extension off of an image file. Could be improved to look for last ',' and grab all after in case of variations like '.jpeg'.
Created: 1459875200
View "image extension"
<mvt:assign name="g.url" value="'http://dev.mcrmedical.com/mm5/graphics/00000001/fak28-MCR-first-aid-kit-front.jpg'" /> <mvt:assign name="g.extension" value="substring(g.url,(len(g.url)-3),4)" /> &mvt:global:extension;
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456865839
View "MivaScript Operators"
<h1>MivaScript Operator Examples</h1> <h2><a href="http://www.mivascript.com/topic/operators.html">Documentation</a></h2> <h2><a href="http://snippets.miva.com/id/1456864554/latest">snippets.miva.com Examples</a></h2> <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456865827
View "MivaScript Operators"
<h1>MivaScript Operator Examples</h1> <h2><a href="http://www.mivascript.com/topic/operators.html">Documentation</a></h2> <h2><a href="http://snippets.miva.com/id/1456864554/latest">snippets.miva.com Examples</a></h2>c <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

MivaScript Operators

 mivascript  operators  NOT  ROUND  CRYPT  MOD  POW  math  string  IN  CIN  EIN  ECIN  EQ  LT  LE  GT  GE  ISNULL  AND  OR
Created: 1456864554
View "MivaScript Operators"
<h1><A href="http://www.mivascript.com/topic/operators.html">MivaScript Operators</A></h1> <mvt:assign name="g.counter" value="1" /> <h2><code>NOT</code></h2> NOT 0: <mvt:eval expr="NOT 0" /><br> NOT 1: <mvt:eval expr="NOT 1" /><br> NOT '': <mvt:eval expr="NOT ''" /><br> NOT 'foobar': <mvt:eval expr="NOT 'foobar'" /><br> <h2><code>ROUND</code></h2> <mvt:assign name="g.PI" value="3.14159265359" /> g.PI: &mvte:global:PI;<br> g.PI ROUND 0: <mvt:eval expr="g.PI ROUND 0" /><br> g.PI ROUND 1: <mvt:eval expr="g.PI ROUND 1" /><br> g.PI ROUND 2: <mvt:eval expr="g.PI ROUND 2" /><br> g.PI ROUND 3: <mvt:eval expr="g.PI ROUND 3" /><br> <h2><code>CRYPT</code></h2> <mvt:assign name="g.password" value="'open-sesame'" /> g.password: &mvte:global:password;<br> g.password CRYPT 'key': <mvt:eval expr="g.password CRYPT 'key'" /><br> g.password CRYPT 'other-key': <mvt:eval expr="g.password CRYPT 'other-key'" /><br> <h2><code>MOD</code></h2> 3 MOD 3: <mvt:eval expr="3 MOD 3"/><br> 4 MOD 3: <mvt:eval expr="4 MOD 3"/><br> 5 MOD 3: <mvt:eval expr="5 MOD 3"/><br> 6 MOD 3: <mvt:eval expr="6 MOD 3"/><br> 7 MOD 3: <mvt:eval expr="7 MOD 3"/><br> 8 MOD 3: <mvt:eval expr="8 MOD 3"/><br> 9 MOD 3: <mvt:eval expr="9 MOD 3"/><br> <h2><code>POW</code></h2> 2 POW 1: <mvt:eval expr="2 POW 1"/><br> 2 POW 2: <mvt:eval expr="2 POW 2"/><br> 2 POW 0: <mvt:eval expr="2 POW 0"/><br> 2 POW 3: <mvt:eval expr="2 POW 3"/><br> 2 POW 4: <mvt:eval expr="2 POW 4"/><br> <h2><code>+-*/</code> <small>Math Operators</small></h2> 3 + 3: <mvt:eval expr="3 + 3"/><br> 3 - 3: <mvt:eval expr="3 - 3"/><br> 3 * 3: <mvt:eval expr="3 * 3"/><br> 3 / 3: <mvt:eval expr="3 / 3"/><br> <h2><code>$</code> <small>String Concatination</small></h2> 'foo' $ 'bar': <mvt:eval expr="'foo' $ 'bar'"/><br> <mvt:assign name="g.name" value="'John'" /> 'Hello ' $ g.name: <mvt:eval expr="'Hello ' $ g.name"/><br> <h2><code>IN</code> <small>First String Position (Case Sensitive)</small></h2> 'apple' IN 'Banana': <mvt:eval expr="'apple' IN 'Banana'"/><br> 'ba' IN 'Banana': <mvt:eval expr="'ba' IN 'Banana'"/><br> 'Ba' IN 'Banana': <mvt:eval expr="'Ba' IN 'Banana'"/><br> 'an' IN 'Banana': <mvt:eval expr="'an' IN 'Banana'"/><br> <h2><code>CIN</code> <small>First String Position (Case In-sensitive)</small></h2> 'apple' CIN 'Banana': <mvt:eval expr="'apple' CIN 'Banana'"/><br> 'ba' CIN 'Banana': <mvt:eval expr="'ba' CIN 'Banana'"/><br> 'Ba' CIN 'Banana': <mvt:eval expr="'Ba' CIN 'Banana'"/><br> 'an' CIN 'Banana': <mvt:eval expr="'an' CIN 'Banana'"/><br> <h2><code>EIN</code> <small>Last String Position (Case Sensitive)</small></h2> 'apple' EIN 'Banana': <mvt:eval expr="'apple' EIN 'Banana'"/><br> 'ba' EIN 'Banana': <mvt:eval expr="'ba' EIN 'Banana'"/><br> 'Ba' EIN 'Banana': <mvt:eval expr="'Ba' EIN 'Banana'"/><br> 'an' EIN 'Banana': <mvt:eval expr="'an' EIN 'Banana'"/><br> ('an' IN 'Banana') !== ('an' EIN 'Banana'): (<mvt:eval expr="'an' IN 'Banana'"/>) !== (<mvt:eval expr="'an' EIN 'Banana'"/>)<br> <h2><code>ECIN</code> <small>Last String Position (Case In-sensitive)</small></h2> 'apple' ECIN 'Banana': <mvt:eval expr="'apple' ECIN 'Banana'"/><br> 'ba' ECIN 'Banana': <mvt:eval expr="'ba' ECIN 'Banana'"/><br> 'Ba' ECIN 'Banana': <mvt:eval expr="'Ba' ECIN 'Banana'"/><br> 'an' ECIN 'Banana': <mvt:eval expr="'an' ECIN 'Banana'"/><br> ('an' CIN 'Banana') !== ('an' ECIN 'Banana'): (<mvt:eval expr="'an' CIN 'Banana'"/>) !== (<mvt:eval expr="'an' ECIN 'Banana'"/>)<br> <h2>Value Comparison Opperators</h2> <h3><code>EQ</code></h3> 1 EQ 1: <mvt:eval expr="1 EQ 1"/><br> 1 EQ '1': <mvt:eval expr="1 EQ '1'"/><br> 1 EQ '01': <mvt:eval expr="1 EQ '01'"/><br> 1 EQ 2: <mvt:eval expr="1 EQ 2"/><br> 1 EQ 0: <mvt:eval expr="1 EQ 0"/><br> 1 EQ '': <mvt:eval expr="1 EQ ''"/><br> <h3><code>NE</code></h3> 1 NE 1: <mvt:eval expr="1 NE 1"/><br> 1 NE '1': <mvt:eval expr="1 NE '1'"/><br> 1 NE '01': <mvt:eval expr="1 NE '01'"/><br> 1 NE 2: <mvt:eval expr="1 NE 2"/><br> 1 NE 0: <mvt:eval expr="1 NE 0"/><br> 1 NE '': <mvt:eval expr="1 NE ''"/><br> <h3><code>LT</code></h3> 1 LT 1: <mvt:eval expr="1 LT 1"/><br> 1 LT '1': <mvt:eval expr="1 LT '1'"/><br> 1 LT '01': <mvt:eval expr="1 LT '01'"/><br> 1 LT 2: <mvt:eval expr="1 LT 2"/><br> 1 LT 0: <mvt:eval expr="1 LT 0"/><br> 1 LT '': <mvt:eval expr="1 LT ''"/><br> <h3><code>LE</code></h3> 1 LE 1: <mvt:eval expr="1 LE 1"/><br> 1 LE '1': <mvt:eval expr="1 LE '1'"/><br> 1 LE '01': <mvt:eval expr="1 LE '01'"/><br> 1 LE 2: <mvt:eval expr="1 LE 2"/><br> 1 LE 0: <mvt:eval expr="1 LE 0"/><br> 1 LE '': <mvt:eval expr="1 LE ''"/><br> <h3><code>GT</code></h3> 1 GT 1: <mvt:eval expr="1 GT 1"/><br> 1 GT '1': <mvt:eval expr="1 GT '1'"/><br> 1 GT '01': <mvt:eval expr="1 GT '01'"/><br> 1 GT 2: <mvt:eval expr="1 GT 2"/><br> 1 GT 0: <mvt:eval expr="1 GT 0"/><br> 1 GT '': <mvt:eval expr="1 GT ''"/><br> <h3><code>GE</code></h3> 1 GE 1: <mvt:eval expr="1 GE 1"/><br> 1 GE '1': <mvt:eval expr="1 GE '1'"/><br> 1 GE '01': <mvt:eval expr="1 GE '01'"/><br> 1 GE 2: <mvt:eval expr="1 GE 2"/><br> 1 GE 0: <mvt:eval expr="1 GE 0"/><br> 1 GE '': <mvt:eval expr="1 GE ''"/><br> <h3><code>ISNULL</code></h3> ISNULL 1: <mvt:eval expr="ISNULL 1"/><br> ISNULL '1': <mvt:eval expr="ISNULL '1'"/><br> ISNULL '01': <mvt:eval expr="ISNULL '01'"/><br> ISNULL 2: <mvt:eval expr="ISNULL 2"/><br> ISNULL 0: <mvt:eval expr="ISNULL 0"/><br> ISNULL '': <mvt:eval expr="ISNULL ''"/><br> <h2>Logical Comparison Opperators</h2> <h2><code>AND</code></h2> 1 AND 1: <mvt:eval expr="1 AND 1"/><br> 1 AND 0: <mvt:eval expr="1 AND 0"/><br> 1 EQ 1 AND 2 EQ 2: <mvt:eval expr="1 EQ 1 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 2: <mvt:eval expr="1 EQ 2 AND 2 EQ 2"/><br> 1 EQ 2 AND 2 EQ 3: <mvt:eval expr="1 EQ 2 AND 2 EQ 3"/><br> <h2><code>OR</code></h2> 1 OR 1: <mvt:eval expr="1 OR 1"/><br> 1 OR 0: <mvt:eval expr="1 OR 0"/><br> 1 EQ 1 OR 2 EQ 2: <mvt:eval expr="1 EQ 1 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 2: <mvt:eval expr="1 EQ 2 OR 2 EQ 2"/><br> 1 EQ 2 OR 2 EQ 3: <mvt:eval expr="1 EQ 2 OR 2 EQ 3"/><br>
 

capitalize

capitalize a string
Created: 1453744065
View "capitalize"
<mvt:assign name="g.str" value="'caleb'" /> <mvt:assign name="g.capitalize" value="toupper(substring(g.str,0,1)) $ subString(g.str,2,len(g.str))" /> &mvt:global:capitalize;
 

capitalize

capitalize a string
Created: 1453743986
View "capitalize"
<mvt:assign name="g.str" value="'caleb'" /> <mvt:assign name="g.firstLetter" value="substring(g.str,0,1)" /> <mvt:assign name="g.capitalize" value="toupper(g.firstLetter) $ subString(g.str,2,len(g.str))" /> &mvt:global:capitalize;
 

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;
 
View "Credit Card Number Formatter & Cleaner "
<mvt:assign name="g.cc_num_dirty" value="'4444-5555/3333A1111-adasdsadasdas!'" /> <mvt:while expr="l.character_counter LT len(g.cc_num_dirty)"> <mvt:assign name="l.character_counter" value="l.character_counter + 1" /> <mvt:assign name="l.character" value="substring_var( g.cc_num_dirty, l.character_counter, 1 )"/> <mvt:if expr="isdigit(l.character)"> <mvt:if expr="l.digit_counter GT 0 AND l.digit_counter MOD 4 EQ 0"> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ '-'" /> </mvt:if> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ l.character" /> <mvt:assign name="l.digit_counter" value="l.digit_counter + 1" /> </mvt:if> </mvt:while> &mvte:global:cc_num_clean;
 
View "Credit Card Number Formatter & Cleaner "
<mvt:assign name="g.cc_num_dirty" value="'4444-5555/3333A1111-adasdsadasdas!'" /> <mvt:while expr="l.character_counter LT len(g.cc_num_dirty)"> <mvt:assign name="l.character_counter" value="l.character_counter + 1" /> <mvt:assign name="l.character" value="substring_var( g.cc_num_dirty, l.character_counter, 1 )"/> <mvt:if expr="isdigit(l.character)"> <mvt:if expr="l.digit_counter GT 0 AND l.digit_counter MOD 4 EQ 0"> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ '-'" /> </mvt:if> <mvt:assign name="g.cc_num_clean" value="g.cc_num_clean $ l.character" /> <mvt:assign name="l.digit_counter" value="l.digit_counter + 1" /> </mvt:if> </mvt:while> &mvte:global:cc_num_clean;