ocaml regex issue on "{{" -
i trying match "{{" in string:
let regexp = str.regexp_string "{{" let _ = if str.string_match regexp "a{{hello}}" 0 print_string "yes" else print_string "no"
this prints "no".
why not matching? "{" not special character: $^.*+?[]
unless reading manual incorrectly, string_match supposed find substring of s satisfies regexp.
you should use str.search_forward
instead.
according ocaml docs:
string_match r s start tests whether substring of s starts @ position start matches regular expression r.
i guessing means doesn't traverse through entire string search_forward
does.
Comments
Post a Comment