Commit 139e59e1 authored by Pietro Abate's avatar Pietro Abate

[r2003-11-24 14:25:16 by szach] - added concatenation function

- added Pcre module which wraps some Pcre functions so that they can
  work on Utf8.t values

Original author: szach
Date: 2003-11-24 14:25:16+00:00
parent 8f26f059
......@@ -183,4 +183,18 @@ struct
let serialize_sub t s i j =
Serialize.Put.substring t s i (j - i)
let concat s1 s2 = s1 ^ s2
module Pcre =
struct
let pcre_replace ~rex ?templ s =
match templ with
| None -> mk (Pcre.replace ~rex (get_str s))
| Some templ ->
mk (Pcre.replace ~rex ~templ:(get_str templ) (get_str s))
let pcre_extract ~rex s = Array.map mk (Pcre.extract ~rex (get_str s))
let pcre_regexp s = Pcre.regexp ~flags:[`UTF8] s
let pcre_split ~rex s = List.map mk (Pcre.split ~rex (get_str s))
end
end
......@@ -23,9 +23,24 @@ sig
val advance: t -> uindex -> uindex
val next: t -> uindex -> uchar * uindex
val concat: t -> t -> t
val store: Buffer.t -> uchar -> unit
val copy: Buffer.t -> t -> uindex -> uindex -> unit
val get_substr: t -> uindex -> uindex -> string
val serialize_sub: Serialize.Put.t -> t -> uindex -> uindex -> unit
module Pcre:
(* Wrappers for some Pcre functions working on Utf8.t values.
* Given Pcre.regexp regular expressions should be compiled with `UTF8 flag
* or with pcre_regexp below *)
sig
val pcre_regexp: string -> Pcre.regexp (* compile using `UTF8 flag *)
val pcre_replace: rex:Pcre.regexp -> ?templ:t -> t -> t
val pcre_extract: rex:Pcre.regexp -> t -> t array
val pcre_split: rex:Pcre.regexp -> t -> t list
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment