How to write regular expressions in ocaml?
How can I write a regular expression for "z1" + "z2" (z1 or z2) ?
I tried this way, but it is giving me errors.
let p = Str.regexp "("z1")|("z2")";;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you intend to match double quotes in your input you should escape them:
And you can shorten the alternation using
z1|z2:Otherwise, if double quotes aren’t part of the input, the pattern should be: