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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -