string regex function added

This commit is contained in:
2021-10-26 22:02:40 +02:00
parent 8d90513a6b
commit 80d7935974
6 changed files with 93 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
|-b|Skips loadin of std lib|
|-c code|Runs given code|
|-f source_file ..|Executes code in files|
|-run source_file ..|Executes code in file, if first line of file is sheebang, it is skipped|
|-i|Runs REPL|
|-d|Turns on better stacktrace|
|-p|Prints profile info at the end|
@@ -103,10 +104,11 @@
|`start-of-year datetime`||`>>> (start-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1609459200`|
|`end-of-year datetime`||`>>> (end-of-year (str-to-date "2021-05-13 10:32:12" "%Y-%m-%d %H:%M:%S")) => 1640995199`|
|`(debug ..)`|||
|`(display ..)`|||
|`(display ..)`|Displays passed parameters|`>>> (display '(1 2 3)) => "(1 2 3)"`|
|`(string-replace source substr replacement)`|Replace a substring with a replacement string in a source string|`>>> (string-replace "abcdefg" "de" "DE") => "abcDEfg"`|
|`(string-replace-re source substr replacement)`|Replace a substring regex with a replacement string in a source string|`>>> (string-replace-re "there is a subsequence in the string" "\\b(sub)([^ ]*)" "sub-$2") => "there is a sub-sequence in the string"`|
|`(string-regex? where regex)`| Returns true if where contains regex|`>>> (string-regex? "aba123cdefg" "[0-9]+") => 1`|
|`(string-regex-list where regex [mode] [ignorecase])`| Returns list of substring from where captured by regex in mode match or tokens|`>>> (string-regex-list "<td class=\"xyz\">1</td><td>2</td>" "<td.*?>(.*?)</td>" "match" "ignore") => (("<td class=\"xyz\">1</td>" "<td>2</td>"))` `>>> (string-regex-list "<td class=\"xyz\">1</td><td>2</td>" "<td.*?>(.*?)</td>" "token") => (("1") ("2"))`|
|`(string-pad str len char rpad_lpad)`|||
|`(string-lpad str len char)`|Pad string from start with char to length len|`>>> (string-lpad "0" 10 "x") => "xxxxxxxxx0"`|
|`(string-rpad str len char)`|Pad string from righ with char to length len|`>>> (string-rpad "0" 10 "x") => "0xxxxxxxxx"`|