core: check that regex is not NULL in function string_replace_regex