September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -0,0 +1 @@
|
|||
(regex "[bB]+" "AbBBbABbBAAAA") -> ("bBBb" 1 4)
|
||||
11
Task/Regular-expressions/Ol/regular-expressions.ol
Normal file
11
Task/Regular-expressions/Ol/regular-expressions.ol
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
; matching:
|
||||
(define regex (string->regex "m/aa(bb|cc)dd/"))
|
||||
(print (regex "aabbddx")) ; => true
|
||||
(print (regex "aaccddx")) ; => true
|
||||
(print (regex "aabcddx")) ; => false
|
||||
|
||||
; substitute part of a string:
|
||||
(define regex (string->regex "s/aa(bb|cc)dd/HAHAHA/"))
|
||||
(print (regex "aabbddx")) ; => HAHAHAx
|
||||
(print (regex "aaccddx")) ; => HAHAHAx
|
||||
(print (regex "aabcddx")) ; => false
|
||||
11
Task/Regular-expressions/Rust/regular-expressions.rust
Normal file
11
Task/Regular-expressions/Rust/regular-expressions.rust
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use regex::Regex;
|
||||
|
||||
fn main() {
|
||||
let s = "I am a string";
|
||||
|
||||
if Regex::new("string$").unwrap().is_match(s) {
|
||||
println!("Ends with string.");
|
||||
}
|
||||
|
||||
println!("{}", Regex::new(" a ").unwrap().replace(s, " another "));
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|re s s1|
|
||||
re := 'm[a-z]+ing' asRegex.
|
||||
s := 'this is a matching string'.
|
||||
|
||||
(re search: s) ifTrue: [ 'matches!' ].
|
||||
|
||||
s1 := re copy: s replacingMatchesWith: 'modified'.
|
||||
Loading…
Add table
Add a link
Reference in a new issue