PDA

View Full Version : Help with Ocaml regular expressions!!


delladella
07-24-2006, 03:37 PM
Hello, nice to be on the forum:
I needed some assistance on how to write regular expressions in Ocaml.
I am currently using the global_replace function which is part of the STR built in library.
Let's say I have a string called x.
let x = "abc /* d**ef */ bdd";;

What I need to do is write a regular expression that will take out he comments "/*" and everything inbetween them. So x will equal "abc bdd".

I currently have
let x = "abc /* d**ef */ bdd";;
let y = "";;
Str.global_replace(Str.regexp(" need something here ")) y x;;

The only regular expression I can come up with only takes out the '/*', '*/' and not the stuff inbetween.

Thanks