Prev | Current Page 407 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


i case insensitive The matches are case insensitive.
m multiline The start (^) and end ($) anchors (see below) work on the beginning
and end of the string and not on each new line as by default.
s single-line The dot (.) character matches also the newline characters
considering the whole string as a single line. This option is only
available in Neko.
u utf-8 Activates the UTF-8 mode. This only affects the Neko platform
because in Flash it is always active and in JavaScript it depends on
current page encoding.
Chapter 8: Cross Platform Tools
213
while (re.match(s))
{
results.add(re.matched(1));
s = re.matchedRight();
}
trace(results); // {quick, brown, jumps, over, lazy }
}
}
The split() method uses the pattern expression to divide a string into chunks. The g option allows
splitting the whole expression and not just the first occurrence.
class Main
{
public static function main()
{
var re = ~/x/g;
var a = re.split(???axbxc??™);
trace(a); // [a, b, c]
}
}
Groups are not used to split strings; only the whole pattern can be used for this purpose.


Pages:
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419