@@ -56,9 +56,9 @@ type re_term =
56
56
(* *********************************************************************)
57
57
(* Final types *)
58
58
59
- type regexp = Pcre .regexp
59
+ type regexp = Pcre2 .regexp
60
60
type split_result = Str .split_result = Text of string | Delim of string
61
- type result = Pcre .substrings
61
+ type result = Pcre2 .substrings
62
62
63
63
(* *********************************************************************)
64
64
(* Parse Str-style regexps, and convert to Pcre-style regexps *)
@@ -268,9 +268,9 @@ let pcre_safe_quote c =
268
268
269
269
let rec print_pcre_regexp ret =
270
270
match ret with
271
- | Texact s -> Pcre . quote s
271
+ | Texact s -> Pcre2 . quote s
272
272
| Tnullchar ->
273
- (* Pcre .quote "\000" returns nonsense *)
273
+ (* Pcre2 .quote "\000" returns nonsense *)
274
274
" [\\ 000]"
275
275
| Tany -> " ."
276
276
| Tnull -> " (?:)"
@@ -315,42 +315,42 @@ and print_set s =
315
315
let regexp s =
316
316
let ret = scan_str_regexp s in
317
317
let s' = print_pcre_regexp ret in
318
- Pcre . regexp ~flags: [ `MULTILINE ] s'
318
+ Pcre2 . regexp ~flags: [ `MULTILINE ] s'
319
319
320
320
let search_forward pat s pos =
321
- let result = Pcre . exec ~rex: pat ~pos s in
322
- (fst (Pcre . get_substring_ofs result 0 ), result)
321
+ let result = Pcre2 . exec ~rex: pat ~pos s in
322
+ (fst (Pcre2 . get_substring_ofs result 0 ), result)
323
323
324
324
let matched_string result _ =
325
- (* Unfortunately, Pcre .get_substring will not raise Not_found if there is
325
+ (* Unfortunately, Pcre2 .get_substring will not raise Not_found if there is
326
326
* no matched string. Instead, it returns "", but this value cannot be
327
327
* distinguished from an empty match.
328
- * The workaround is to call Pcre .get_substring_ofs first. This function
328
+ * The workaround is to call Pcre2 .get_substring_ofs first. This function
329
329
* will raise Not_found if there is not any matched string.
330
330
*
331
331
* NOTE: Current versions of Pcre do return Not_found!
332
332
*)
333
- ignore (Pcre . get_substring_ofs result 0 );
334
- Pcre . get_substring result 0
333
+ ignore (Pcre2 . get_substring_ofs result 0 );
334
+ Pcre2 . get_substring result 0
335
335
336
- let match_beginning result = fst (Pcre . get_substring_ofs result 0 )
337
- let match_end result = snd (Pcre . get_substring_ofs result 0 )
336
+ let match_beginning result = fst (Pcre2 . get_substring_ofs result 0 )
337
+ let match_end result = snd (Pcre2 . get_substring_ofs result 0 )
338
338
339
339
let matched_group result n _ =
340
340
(* See also the comment for [matched_string] *)
341
- if n < 0 || n > = Pcre . num_of_subs result then raise Not_found ;
342
- ignore (Pcre . get_substring_ofs result n);
343
- Pcre . get_substring result n
341
+ if n < 0 || n > = Pcre2 . num_of_subs result then raise Not_found ;
342
+ ignore (Pcre2 . get_substring_ofs result n);
343
+ Pcre2 . get_substring result n
344
344
345
345
let global_substitute pat subst s =
346
- Pcre . substitute_substrings ~rex: pat ~subst: (fun r -> subst r s) s
346
+ Pcre2 . substitute_substrings ~rex: pat ~subst: (fun r -> subst r s) s
347
347
348
348
let tr_split_result r =
349
349
List. map
350
350
(function
351
- | Pcre .Text t -> Text t | Pcre .Delim d -> Delim d | _ -> assert false )
351
+ | Pcre2 .Text t -> Text t | Pcre2 .Delim d -> Delim d | _ -> assert false )
352
352
(List. filter
353
- (function Pcre .Group (_ , _ ) | Pcre .NoGroup -> false | _ -> true )
353
+ (function Pcre2 .Group (_ , _ ) | Pcre2 .NoGroup -> false | _ -> true )
354
354
r)
355
355
356
- let full_split sep s = tr_split_result (Pcre . full_split ~rex: sep ~max: (- 1 ) s)
356
+ let full_split sep s = tr_split_result (Pcre2 . full_split ~rex: sep ~max: (- 1 ) s)
0 commit comments