RosettaCodeData/Task/Regular-expressions/Toka/regular-expressions.toka
2023-07-01 13:44:08 -04:00

19 lines
580 B
Text

#! Include the regex library
needs regex
#! The two test strings
" This is a string" is-data test.1
" Another string" is-data test.2
#! Create a new regex named 'expression' which tries
#! to match strings beginning with 'This'.
" ^This" regex: expression
#! An array to store the results of the match
#! (Element 0 = starting offset, Element 1 = ending offset of match)
2 cells is-array match
#! Try both test strings against the expression.
#! try-regex will return a flag. -1 is TRUE, 0 is FALSE
expression test.1 2 match try-regex .
expression test.2 2 match try-regex .