; ; @ANO_SCRIPT_NAME regex_tests ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Simple regex example ; ; @ANO_FLAGS_USE_PROTOS [ ] ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2026, Jani Salonen ; All rights reserved. ; ; Example to play with regular expressions. ; main [exit: 0] { mov _string ("Hello, world!") ; Test match... ; regex_test (\ pattern: "World", \ string: _string, \ flags: "") print "Test returned " . rc . " when testing '" . _string . \ "' with string 'World'\nusing case sensitive match.\n" ; ...and other way round. ; regex_test (\ pattern: "World", \ string: _string, \ flags: "i") print "Test returned " . rc . " when testing '" . _string . \ "' with string 'World'\nusing case insensitive match.\n" ; Get matched substring. ; regex_match (\ pattern: "world", \ string: _string, \ flags: "i") print "Match returned '" . rc . "' matching '" . _string . \ "' with string 'world'\nusing case insensitive match.\n" ; Replace one occurrence. ; regex_subs (\ pattern: "world", \ string: _string, \ replace: "Finland", \ flags: "") print "Substitution returned '" . rc . "' matching '" . _string . \ "'\nreplacing string 'world' with 'Finland' using case" \ " sensitive match.\n" ; Global replace. ; regex_subs (\ pattern: "l", \ string: _string, \ replace: "x", \ flags: "gi") print "Substitution returned '" . rc . "' matching '" . _string . \ "'\nreplacing character 'l' with 'x' using case sensitive" \ " global match.\n" }