Skip to content

Commit

Permalink
New release for eo-strings-0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor authored and yegor256 committed Jul 4, 2023
1 parent 9e05dc7 commit a459ef8
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 18 deletions.
4 changes: 2 additions & 2 deletions objects/org/eolang/txt/regex.eo
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
+architect [email protected]
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+rt jvm org.eolang:eo-strings:0.2.0
+version 0.2.0
+rt jvm org.eolang:eo-strings:0.4.0
+version 0.4.0

# Regular expression in Perl format.
# Free attribute "r" is a string represenation of regex object.
Expand Down
4 changes: 2 additions & 2 deletions objects/org/eolang/txt/sprintf.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
+architect [email protected]
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+rt jvm org.eolang:eo-strings:0.2.0
+version 0.2.0
+rt jvm org.eolang:eo-strings:0.4.0
+version 0.4.0

[format args...] > sprintf /string
4 changes: 2 additions & 2 deletions objects/org/eolang/txt/sscanf.eo
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
+architect [email protected]
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+rt jvm org.eolang:eo-strings:0.2.0
+version 0.2.0
+rt jvm org.eolang:eo-strings:0.4.0
+version 0.4.0

# Reads formatted input from a string.
# This object with two free attributes:
Expand Down
129 changes: 125 additions & 4 deletions objects/org/eolang/txt/text.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
+architect [email protected]
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+rt jvm org.eolang:eo-strings:0.2.0
+version 0.2.0
+rt jvm org.eolang:eo-strings:0.4.0
+version 0.4.0

[s] > text
s > @
Expand All @@ -36,6 +36,35 @@
text > @
^.s.slice start len

# Returns string trimmed from left side
[] > left-trim
left-rec-trim > @
s

[str] > left-rec-trim
if. > @
eq.
length.
str
0
""
if.
eq.
slice.
str
0
1
" "
left-rec-trim
slice.
str
1
plus.
length.
str
-1
str

# Trim it from both sides
[] > trimmed
rec-trim > @
Expand Down Expand Up @@ -100,6 +129,27 @@
(acc.concat x.as-bytes).concat s.as-bytes
res.as-string > @

# Returns string repeated n times
[n] > repeated
rec-repeated > @
s
n

[str n] > rec-repeated
if. > @
eq.
n
0
""
chained.
text
str
rec-repeated
str
minus.
n
1

# Checks that string contains substr
[substr] > contains
substr.length > len!
Expand Down Expand Up @@ -372,7 +422,7 @@
# Returns an tuple of strings, separated by a given string
[delimiter] > split /tuple

# Check that all signs in string are letters.
# Check that all signs in string are numbers or letters.
# Works only for english letters
[] > is-alphabetic
reduced. > @
Expand All @@ -388,6 +438,49 @@
bytes-1-to-8
as-bytes.
x
and. > @
a
int-is-alphabetic
value

[b] > int-is-alphabetic
or. > @
and.
gte.
b
48
lte.
b
57
and.
gte.
b
97
lte.
b
122

[b] > bytes-1-to-8
concat. > @
00-00-00-00-00-00-00
b

# Check that all signs in string are letters.
# Works only for english letters
[] > is-alpha
reduced. > @
list
bytes-as-array
as-bytes.
low-cased.
text
s
TRUE
[a x]
as-int. > value!
is-alphabetic.bytes-1-to-8
as-bytes.
x
and. > @
a
int-is-alpha
Expand All @@ -407,7 +500,35 @@
00-00-00-00-00-00-00
b

# Returns concatenaion of all strings
# Check that all signs in string are ASCII characters.
[] > is-ascii
reduced. > @
list
bytes-as-array
as-bytes.
text
s
TRUE
[a x]
as-int. > value!
is-alphabetic.bytes-1-to-8
as-bytes.
x
and. > @
a
int-is-ascii
value

[b] > int-is-ascii
and. > @
gte.
b
0
lte.
b
127

# Returns concatenation of all strings
[others...] > chained
text > @
as-string.
Expand Down
Binary file added py/__pycache__/deps.cpython-38.pyc
Binary file not shown.
57 changes: 56 additions & 1 deletion tests/org/eolang/txt/regex-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+tests
+version 0.2.0
+version 0.4.0

[] > matches-string-against-pattern
assert-that > @
Expand Down Expand Up @@ -223,3 +223,58 @@
"abxxxxxcd"
""
$.equal-to "abcd"

[] > replace-groups-1
nop > @
assert-that
regex.replaced.replacei.replace-by-groups
QQ.txt.text "q$0wer$1ty"
list
*
"GR0"
"GR1"
$.equal-to
"qGR0werGR1ty"

[] > group-ref-0
nop > @
assert-that
replaced.
compile.
regex "/(([A-Za-z])[0-9])/"
"A2B"
"G$1G"
$.equal-to
"GA2GB"

[] > group-ref-1
nop > @
assert-that
replaced.
compile.
QQ.txt.regex "/(([A-Za-z])[0-9])/"
"a1a"
"G$1G"
$.equal-to
"Ga1Ga"

[] > group-ref-2
nop > @
assert-that
replaced.
compile.
QQ.txt.regex "/([xyz]+)/"
"abxxxcd"
"$0"
$.equal-to "abxxxcd"

[] > group-ref-3
nop > @
assert-that
replaced.
compile.
QQ.txt.regex "/(([A-Za-z])[0-9])/"
"a1a\n"
"$1世"
$.equal-to
"a1世a\n"
2 changes: 1 addition & 1 deletion tests/org/eolang/txt/sprintf-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+tests
+version 0.2.0
+version 0.4.0

[] > prints-simple-string
assert-that > @
Expand Down
2 changes: 1 addition & 1 deletion tests/org/eolang/txt/sscanf-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
+home https://github.com/objectionary/eo-strings
+package org.eolang.txt
+tests
+version 0.2.0
+version 0.4.0

[] > sscanf-with-string
assert-that > @
Expand Down
Loading

0 comments on commit a459ef8

Please sign in to comment.