Str module : erase double-quoted strings
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
I've always found the syntax of Str-regexps rather confusing. Here
is my latest headache : in a text I want to erase all double-quoted
(à la OCaml) strings. Thus, abc"def"ghi"jk"lm"nop"qr should be turned into abcghilmqr.
Seems pretty simple, doesn't it ?
Here is my failed attempt :
OCaml version 4.02.1
# let initial_text="abc\"def\"ghi\"jk\"lm\"nop\"qr";;
val initial_text : string = "abc\"def\"ghi\"jk\"lm\"nop\"qr"
# let double_quote=Str.quote "\"";;
val double_quote : string = "\""
# let rgxp=Str.regexp(double_quote^"."^double_quote)
;;
val rgxp : Str.regexp = <abstr>
# let answer=Str.global_replace rgxp "" initial_text;;
val answer : string = "abc\"def\"ghi\"jk\"lm\"nop\"qr"