Split s using self is separator.

Returns an array of matches that are between each occurence of self. If self is not present, an array with a single match on s is retunred.

assert 'l'.split_in("hello world").join("|")  == "he||o wor|d"
assert 'z'.split_in("hello world").join("|")  == "hello world"

Note: is used by String::split

Property definitions

core $ Pattern :: split_in
	# Split `s` using `self` is separator.
	#
	# Returns an array of matches that are between each occurence of `self`.
	# If self is not present, an array with a single match on `s` is retunred.
	#
	#     assert 'l'.split_in("hello world").join("|")  == "he||o wor|d"
	#     assert 'z'.split_in("hello world").join("|")  == "hello world"
	#
	# Note: is used by `String::split`
	protected fun split_in(s: Text): Array[Match]
	do
		var res = new Array[Match] # Result
		var i = 0 # Cursor
		var match = search_in(s, 0)
		while match != null do
			# Compute the splited part length
			var len = match.from - i
			res.add(new Match(s.to_s, i, len))
			i = match.after
			match = search_in(s, i)
		end
		# Add the last part
		res.add(new Match(s.to_s, i, s.length - i))
		return res
	end
lib/core/text/string_search.nit:62,2--86,4