self
in s
?
# assert "ab".to_re.is_in("abcd")
# assert "ab".to_re.is_in("cdab")
# assert not "ab".to_re.is_in("acdb")
# assert "ab".to_re.is_in("ab")
redef fun is_in(text)
do
var comp_res = compile
assert comp_res == null else "Regex compilation failed with: {comp_res.message}\n".output
var native = native
assert native != null
# Actually execute
var eflags = gather_eflags
var res = native.regexec_match_only(text.to_cstring, eflags)
# Got a match?
if res == 0 then return true
# Got no match, not an error?
if res.is_nomatch then return false
# Error, should be out of memory but we cover any possible error anyway
var error_str = get_error(res)
"Regex search failed with: {error_str}\n".output
abort
end
lib/core/re.nit:288,2--314,4