Dear All,
I am trying to use the Str module to match regular expressions. I want to return the longest match.
let txt = "ab"
let reg = "a\\|ab"
let _ =
let b = Str.string_match (Str.regexp reg) txt 0 in
Str.matched_string txt
After the last line, the string "a" is apparently matched. But I hope that the result should be "ab". If I reverse the order of the alternatives in the regular expression, the string "ab" is matched. I don't want the order of the alternatives to matter. What am I doing wrong? What can I do to match the longest substring?
Thanks
Tom