Get all words between two markers in a string
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
I need to get the list of all value names in a given module. So I put the contents of the mli in a string, and now I need to do some regexp manipulation on it, selecting all words between "val" and ":" that's the part where I'm stuck. So what would be nice here is a grab_value_names:string->string function, such that grab_value_names "**** val get : ***** val set : **** val make : ***" returns ["get";"set";"make"]. I'm not sure about how to do this with the Str module. I thought first of cleaning everything between a ":" and "val" ; I tried the following which doesn't work : let cleanup s=Str.global_replace (Str.regexp ":[.]+val") ":\nval" s;;