June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
5
Task/Regular-expressions/Maple/regular-expressions.maple
Normal file
5
Task/Regular-expressions/Maple/regular-expressions.maple
Normal 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");
|
||||
12
Task/Regular-expressions/Ring/regular-expressions.ring
Normal file
12
Task/Regular-expressions/Ring/regular-expressions.ring
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue