nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: improve examples in documentation
[nit.git]
/
lib
/
standard
/
string_search.nit
diff --git
a/lib/standard/string_search.nit
b/lib/standard/string_search.nit
index
8249bac
..
6f59bac
100644
(file)
--- a/
lib/standard/string_search.nit
+++ b/
lib/standard/string_search.nit
@@
-295,12
+295,12
@@
redef class String
# for i in "hello world".search_all('o') do
# a.add(i.from)
# end
# 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.
#
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)
fun split(p: Pattern): Array[String]
do
var matches = p.split_in(self)
@@
-314,8
+314,8
@@
redef class String
# Replace all occurences of a pattern with a string
#
# 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)
fun replace(p: Pattern, string: String): String
do
return self.split_with(p).join(string)
@@
-323,7
+323,7
@@
redef class String
# Escape the four characters < > & and " with their html counterpart
#
# 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
fun html_escape: String
do
var ret = self