Merge: lib/core: add Text::prefix and Text::suffix
authorJean Privat <jean@pryen.org>
Thu, 12 Nov 2015 01:43:44 +0000 (20:43 -0500)
committerJean Privat <jean@pryen.org>
Thu, 12 Nov 2015 01:43:44 +0000 (20:43 -0500)
commitaf582792879355d333ee07c58643320a2bc353cc
tree2ebff6b2df599a68de2671d47e01e6782d5289c6
parenta3c4be9daed4086b5b027e073ad8dbe432bcbac8
parentf064f347efaa0ba827bdd4a6cca1fce11cda4c08
Merge: lib/core: add Text::prefix and Text::suffix

I wanted a way to detect and possibly remove a prefix from a string but there was no straight-forward way.

So I propose one:

~~~
var str = "hello world"
var p = str.prefix("hello")
assert p != null and p.text_after == " world"
assert str.prefix("fail") == null
~~~

Same with `suffix`

Pull-Request: #1829
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>