Extract a given suffix, if any.

var p = "hello world".suffix("world")
assert p != null
assert p.text_before == "hello "

Property definitions

core :: string_search $ Text :: suffix
	# Extract a given suffix, if any.
	#
	# ~~~
	# var p = "hello world".suffix("world")
	# assert p != null
	# assert p.text_before == "hello "
	# ~~~
	fun suffix(t: Text): nullable Match do
		var len = t.length
		var from = length - len
		if substring(from, len) == t then
			return new Match(self.to_s, from, len)
		end
		return null
	end
lib/core/text/string_search.nit:417,2--431,4