# for i in "hello world".search_all('o') do
# a.add(i.from)
# end
- # a # -> [4, 7]
+ # assert a == [4, 7]
fun search_all(p: Pattern): Array[Match] do return p.search_all_in(self)
# Split `self` using `p` as separator.
#
- # "hello world".split('o') # -> ["hell", " w", "rld"]
+ # assert "hello world".split('o') == ["hell", " w", "rld"]
fun split(p: Pattern): Array[String]
do
var matches = p.split_in(self)
# Replace all occurences of a pattern with a string
#
- # "hlelo".replace("le", "el") # -> "hello"
- # "hello".replace('l', "") # -> "heo"
+ # assert "hlelo".replace("le", "el") == "hello"
+ # assert "hello".replace('l', "") == "heo"
fun replace(p: Pattern, string: String): String
do
return self.split_with(p).join(string)
# Escape the four characters < > & and " with their html counterpart
#
- # "a&b->\"x\"".html_escape # -> "a&b->"x""
+ # assert "a&b->\"x\"".html_escape == "a&b->"x""
fun html_escape: String
do
var ret = self