en:explodex

Explodex (Function)

Format

string_array_variable$ = explodex ( string_expr , regex_expr )

returns string_array that must be assigned to a string_array_variable$

Description

Splits up string_expr into substrings wherever the regular expression regex_expr occurs. Substrings are stored in either the string or numeric array defined in the assignment statement. The array will be re-dimensioned to the exact size to store all of the substrings. Unlike ExPLODE, EXPLODEX allows ignoring specific variations (case sentive, spelling etc), see example below ”[Aa][Nn][Dd]”.

Example

# explode on regex //[,]* //
a$ = "We all live in a yellow submarine, yellow submarine, yellow, submarine."
w$ = explodex(a$,"[,]* ")
for t = 0 to w$[?]-1
   print "w$["+t+"]=" + w$[t]
next t
# explode on regex //[Aa][Nn][Dd]//
a$="1 and 2 AND 3 and 5 aND 99 AND 8.88 aNd 6.45"
n = explodex(a$,"[Aa][Nn][Dd]")
for t = 0 to n[?]-1
   print "n["+t+"]=" + n[t]
next t

will display

We all live in a yellow submarine.
w$[0]=We
w$[1]=all
w$[2]=live
w$[3]=in
w$[4]=a
w$[5]=yellow
w$[6]=submarine
w$[7]=yellow
w$[8]=submarine
w$[9]=yellow
w$[10]=submarine.
n[0]=1
n[1]=2
n[2]=3
n[3]=5
n[4]=99
n[5]=8.88
n[6]=6.45

Notes

By default the nature of regular expressions is “greedy”. This behaviour can be changed using the RegexMinimal statement.

See Also

History

0.9.6.56New to Version
en/explodex.txt · Last modified: 2014/08/06 20:18 by admin