Regular Expressions in Smart Mobile Studio

How to work with regular expressions in Smart Mobile Studio ? For example, how can I code the following example in Object Pascal?

var re = /\w+\s/g;  
var str = "fee fi fo fum";  
var myArray = str.match(re);  
console.log(myArray);
+3
source share
1 answer

In SmartMS, regular expressions are implemented in the w3regex block, so you start by adding w3regexto the list uses.

A "short" form (for example, var re = /\w+\s/g;from a question) is not supported. To create a regular expression object, you must use the constructor.

re := TW3RegEx.Create('\w+\s', 'g');

. , w3regex , , , .

var re := TW3Regex.Create('\w+\s', 'g');
var str := 'fee fi fo fum';
var myArray := str.Match(re);

( , , , .)

w3regex Match, . , :

var myArray: TStrArray = ('fee fi fo fum').Match('\w+\s', 'g');

.

SmartMS RegExDemo, .

+8

All Articles