Espressioni regolari

FINDALL, SEARCH, SUB

SUB

Substitute character sequences using regex (regular expression) patterns.

PRINT SUB (“t”, “T”, “text”) ; print “Text”, replacing “t” with “T”
PRINT SUB (“(.)”, “\\1\\1”, “text”) ; print “tteexxtt”, doubling every characters

SEARCH

Search character sequences patterns using regex patterns.

IF SEARCH (“\w”, word) [ PRINT “Letter in the word.” ]

FINDALL

Find all character sequences in the input string matching the given regex pattern.

PRINT FINDALL(“\w+”, “Dogs, cats.”) ; print [“Dogs”, “cats”], the list of the words

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *