June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -3,6 +3,8 @@
{{omit from|GUISS}}
{{omit from|PARI/GP}}
The goal of this task is
* to match a string against a regular expression
* to substitute part of a string using a regular expression
;Task:
:*   match a string against a regular expression
:*   substitute part of a string using a regular expression
<br><br>

View file

@ -0,0 +1,8 @@
USING: io kernel prettyprint regexp ;
IN: rosetta-code.regexp
"1000000" R/ 10+/ matches? . ! Does the entire string match the regexp?
"1001" R/ 10+/ matches? .
"1001" R/ 10+/ re-contains? . ! Does the string contain the regexp anywhere?
"blueberry pie" R/ \p{alpha}+berry/ "pumpkin" re-replace print

View file

@ -0,0 +1,5 @@
#Examples from Maple Help
StringTools:-RegMatch("^ab+bc$", "abbbbc");
StringTools:-RegMatch("^ab+bc$", "abbbbcx");
StringTools:-RegSub("a([bc]*)(c*d)", "abcd", "&-\\1-\\2");
StringTools:-RegSub("(.*)c(anad[ai])(.*)", "Maple is canadian", "\\1C\\2\\3");

View file

@ -0,0 +1,12 @@
# Project : Regular expressions
# Date : 2018/01/23
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
text = "I am a text"
if right(text,4) = "text"
see "'" + text +"' ends with 'text'" + nl
ok
i = substr(text,"am")
text = left(text,i - 1) + "was" + substr(text,i + 2)
see "replace 'am' with 'was' = " + text + nl