Caml1999I0379H #Str®exp4;@@@A@@@@@'str.mliZ##Z#.@@@@ @@A@®exp5@&stringQ@@@[@@@\@@]@^bb^b@@!A@@0regexp_case_fold6@@@@^@@@_@@`@(NZZ)NZ@@3B@@%quote7@'@@@a+@@@b@@c@;S**<S*F@@FC@@-regexp_string8@:@@@d8@@@e@@f@MWNW@@XD@@7regexp_string_case_fold9@L@@@gJ@@@h@@i@_[00`[0^@@jE@@,string_match:@X@@@j@c@@@k@#intA@@@l$boolE@@@m@@n@@o@@p@c  c <@@F@@.search_forward;@z@@@q@@@@r@"@@@s&@@@t@@u@@v@@w@hh8@@G@@/search_backward<@@@@x@@@@y@@@@@zD@@@{@@|@@}@@~@pyypy@@H@@4string_partial_match=@@@@@@@@@^@@@\@@@@@@@@@@x  x C@@I@@.matched_string>@@@@@@@@@@}}@@J@@/match_beginning?@$unitF@@@@@@@@@@@K@@)match_end@@@@@@@@@@@@@!L@@-matched_groupA@@@@@@@@@@@@@@@@/0@@:M@@/group_beginningB@@@@@@@@@@BC@@MN@@)group_endC@@@@@@@@@@U  V  @@`O@@.global_replaceD@N@@@@Y@@@@_@@@c@@@@@@@@@@s""t"#@@~P@@-replace_firstE@l@@@@w@@@@}@@@@@@@@@@@@@$$$$@@Q@@1global_substituteF@@@@@@@@@@@@@@@@@@@@@@@@@@@@%k%k%k%@@R@@0substitute_firstG@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&'1@@S@@/replace_matchedH@@@@@@@@@@@@@@@@''''@@T@@%splitI@@@@@@@@$listK@@@@@@@@@@@))))@@U@@-bounded_splitJ@ @@@@@@@@@@@%#@@@@@@@@@@@@@4**5*+.@@?V@@+split_delimK@-@@@@8@@@B@@@@@@@@@@@@Q++R++@@\W@@3bounded_split_delimL@J@@@@U@@@@@@@ec@@@@@@@@@@@@@t--u--P@@X@@,split_resultM;@@$Text,x@@@@@ ..  ...@@Z@%Delim-@@@@@ ./.1 ./.B@@[@@@A@@@@@..@@@@Y@A@*full_splitN@@@@@@@@:@@@@@@@@@@@ .D.D .D.z@@\@@2bounded_full_splitO@@@@@@@@@W@@@ʠ#@@@@@@@@@@@@@////@@]@@-string_beforeP@@@@@t@@@@@@@@@@@0001 @@^@@,string_afterQ@@@@@@@@@@@@@@@@ #11 #11@@_@@+first_charsR@ @@@@@@@@@@@@@@@#(2v2v$(2v2@@.`@@*last_charsS@"@@@@@@@,@@@@@@@@<,33=,33A@@Ga@@@a7-#Str0ϭE6h)&Stdlib0Lku]8_٠8CamlinternalFormatBasics0%FU(Q/Tu@@@Caml1999T037!P'DC#Str*ocaml.text&_none_@@A 6 Regular expressions and high-level string processing 'str.mliP77P7r@@@@@@3@@@@#intA;@@@A@@@@@9@A@$charB;@@A@@@@@=@A@&stringQ;@@ A@@@@@A@@@%bytesC;@@ A@@@@@E@@@%floatD;@@A@@@@@I@@@$boolE;@@%falsec@@S@$trued@@Y@@@A@@@@@Z@A@$unitF;@@"()e@@d@@@A@@@@@e@A@ #exnG;@@@A@@@@@i@@@#effH;@@O@A@A@@@@@@r@@@,continuationI;@@Q@@P@BDA@nY@@@@@@@@@ %arrayJ;@@R@AOA@@@@@@@@@$listK;@@S@A"[]f@@@"::g@@@T@@@ @@A@Y@@@@@@@@&optionL;@@V@A$Noneh@@@$Somei@@@@@A@Y@@@@@@@@)nativeintM;@@A@@@@@@@@%int32N;@@A@@@@@@@@%int64O;@@A@@@@@@@@&lazy_tP;@@X@AA@Y@@@@@@@@5extension_constructorR;@@A@@@@@@@@*floatarrayS;@@A@@@@@@@@&iarrayT;@@Y@AA@Y@@@@@@@@*atomic_locU;@@Z@AA@@@@@@@@@.Assert_failure`#@@@@@J@@@@@@@@[@@A=ocaml.warn_on_literal_pattern@0Division_by_zero]#@@@A  @+End_of_file\##@@@A@'FailureY#+@&@@A  @0Invalid_argumentX#4@/@@A&#))@-Match_failureV#=@@<@8@:@@a@@A74::@)Not_foundZ#N@@@A?<B B@-Out_of_memoryW#V@@@AGDJJ@.Stack_overflow^#^@@@AOLRR@.Sys_blocked_io_#f@@@AWTZ"Z@)Sys_error[#n@i@@A`]c+c@:Undefined_recursive_modulea#w@@v@r@t@@h@@Aqnt<t@:Continuation_already_takenb#@@@Ayv|D|@&Stdlib@At9 {1 Regular expressions} SuuSu@@@@@@ The {!Str} library provides regular expressions on sequences of bytes. It is, in general, unsuitable to match Unicode characters. UX!@@@@@@A+®expAZ#(Z#.@@;@@@A@@@@@Z##@)ocaml.doc + The type of compiled regular expressions. [//[/_@@@@@@@@@@@@@A@Ő@@@@@@@"@®exp^bf^bl@б@г&string^bo^bu@@ @@@3@A;@A@@гE®exp^by^b@@ @@@@@@@@@@@^bb @K  Compile a regular expression. The following constructs are recognized: - [. ] Matches any character except newline. - [* ] (postfix) Matches the preceding expression zero, one or several times - [+ ] (postfix) Matches the preceding expression one or several times - [? ] (postfix) Matches the preceding expression once or not at all - [[..] ] Character set. Ranges are denoted with [-], as in [[a-z]]. An initial [^], as in [[^0-9]], complements the set. To include a [\]] character in a set, make it the first character of the set. To include a [-] character in a set, make it the first or the last character of the set. - [^ ] Matches at beginning of line: either at the beginning of the matched string, or just after a '\n' character. - [$ ] Matches at end of line: either at the end of the matched string, or just before a '\n' character. - [\| ] (infix) Alternative between two expressions. - [\(..\)] Grouping and naming of the enclosed expression. - [\1 ] The text matched by the first [\(...\)] expression ([\2] for the second expression, and so on up to [\9]). - [\b ] Matches word boundaries. - [\ ] Quotes special characters. The special characters are [$^\.*+?[]]. In regular expressions you will often use backslash characters; it's easier to use a quoted string literal [{|...|}] to avoid having to escape backslashes. For example, the following expression: {[ let r = Str.regexp {|hello \([A-Za-z]+\)|} in Str.replace_first r {|\1|} "hello world" ]} returns the string ["world"]. If you want a regular expression that matches a literal backslash character, you need to double it: [Str.regexp {|\\|}]. You can use regular string literals ["..."] too, however you will have to escape backslashes. The example above can be rewritten with a regular string literal as: {[ let r = Str.regexp "hello \\([A-Za-z]+\\)" in Str.replace_first r "\\1" "hello world" ]} And the regular expression for matching a backslash becomes a quadruple backslash: [Str.regexp "\\\\"]. _L)X@@@@@@@A@@@[@@@@@@10regexp_case_foldNZ^NZn@б@г蠐&stringNZqNZw@@ @@@3@J_8@A@@г®exp,NZ{-NZ@@ @@@@@@@@@@@7NZZ @ Same as [regexp], but the compiled expression will match text in a case-insensitive way: uppercase and lowercase letters will be considered equivalent. DOEQ(@@@@@@@]B@@@X@@@@@@1%quote[S*.\S*3@б@г1&stringfS*6gS*<@@ @@@3hhhhhhhh@J_8@A@@г@&stringuS*@vS*F@@ @@@@@@@@@@@S** @ݐ U [Str.quote s] returns a regexp string that matches exactly [s] and nothing else. TGGU@@@@@@@C@@@@@@@@@1-regexp_stringWW@б@гz&stringWW@@ @@@3@J_8@A@@г ®expWW@@ @@@@@@@@@@@W @& a [Str.regexp_string s] returns a regular expression that matches exactly [s] and nothing else.XY.@@@@@@@D@@@6ꐠ@@@@@@17regexp_string_case_fold[04[0K@б@гà&string[0N[0T@@ @@@3@J_8@A@@гi®exp[0X[0^@@ @@@@@@@@@@@[00 @o x [Str.regexp_string_case_fold] is similar to {!Str.regexp_string}, but the regexp matches in a case-insensitive way. \__ ]@@@@@@@8E@@@3@@@@@@1A@ # {1 String matching and searching} =`>`@@@@@@3<<<<<<<<@CX1@A,string_matchIc Jc @б@г®expTc Uc #@@ @@@@@б@г.&stringcc 'dc -@@ @@@)@@б@гF#intrc 1sc 4@@ @@@8@@г>$boolc 8c <@@ @@@E@@@@@H@@@%@@K( @@@7@@N:@@@c  @퐠 [string_match r s start] tests whether a substring of [s] that starts at position [start] matches the regular expression [r]. The first character of a string has position [0], as usual. d==f@@@@@@@F@@!@@@@@@@m.search_forwardh h@б@г!®exphh @@ @@@3@8@A@@б@г&stringh$h*@@ @@@@@б@г#inth.h1@@ @@@ @@г#inth5h8@@ @@@-@@@@@0@@@%@@3( @@@9@@6<@@@h@Z 9 [search_forward r s start] searches the string [s] for a substring matching the regular expression [r]. The search starts at position [start] and proceeds towards the end of the string. Return the position of the first character of the matched substring. @raise Not_found if no substring matches.  i99 nHw@@@@@@@#G@@!@j@@@@@@U/search_backward!py}"py@б@г®exp,py-py@@ @@@3........@n8@A@@б@г&string=py>py@@ @@@@@б@г #intLpyMpy@@ @@@ @@г-#intYpyZpy@@ @@@-@@@@@0@@@%@@3( @@@9@@6<@@@jpyy@ǐ T [search_backward r s last] searches the string [s] for a substring matching the regular expression [r]. The search first considers substrings that start at position [last] and proceeds towards the beginning of string. Return the position of the first character of the matched substring. @raise Not_found if no substring matches. wqxv@@@@@@@H@@!@@@@@@@U4string_partial_matchx  x !@б@г®expx $x *@@ @@@3@n8@A@@б@гu&stringx .x 4@@ @@@@@б@г#intx 8x ;@@ @@@ @@г$boolx ?x C@@ @@@-@@@@@0@@@%@@3( @@@9@@6<@@@x  @4 Similar to {!Str.string_match}, but also returns true if the argument string is a prefix of a string that matches. This includes the case of a true complete match. yDD{@@@@@@@I@@!@D@@@@@@U.matched_string}}@б@гѠ&string} }@@ @@@3@n8@A@@гࠐ&string}}@@ @@@@@@@@@@@ } @}  [matched_string s] returns the substring of [s] that was matched by the last call to one of the following matching or searching functions: - {!Str.string_match} - {!Str.search_forward} - {!Str.search_backward} - {!Str.string_partial_match} - {!Str.global_substitute} - {!Str.substitute_first} provided that none of the following functions was called in between: - {!Str.global_replace} - {!Str.replace_first} - {!Str.split} - {!Str.bounded_split} - {!Str.split_delim} - {!Str.bounded_split_delim} - {!Str.full_split} - {!Str.bounded_full_split} Note: in the case of [global_substitute] and [substitute_first], a call to [matched_string] is only valid within the [subst] argument, not after [global_substitute] or [substitute_first] returns. The user must make sure that the parameter [s] is the same string that was passed to the matching or searching function. -~.@@@@@@@FJ@@@A@@@@@@1/match_beginningDE@б@г$unitOP@@ @@@3QQQQQQQQ@J_8@A@@г2#int^_@@ @@@@@@@@@@@i @Ɛ [match_beginning()] returns the position of the first character of the substring that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). vwq@@@@@@@K@@@@@@@@@1)match_end@б@гF$unit@@ @@@3@J_8@A@@г{#int@@ @@@@@@@@@@@ @ [match_end()] returns the position of the character following the last character of the substring that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). @@@@@@@L@@@Ӑ@@@@@@1-matched_group@б@г#int@@ @@@3@J_8@A@@б@г&string@@ @@@@@гʠ&string@@ @@@@@@@@!@@@'@@$* @@@ @j  [matched_group n s] returns the substring of [s] that was matched by the [n]th group [\(...\)] of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). When [n] is [0], it returns the substring matched by the whole regular expression. The user must make sure that the parameter [s] is the same string that was passed to the matching or searching function. @raise Not_found if the [n]th group of the regular expression was not matched. This can happen with groups inside alternatives [\|], options [?] or repetitions [*]. For instance, the empty string will match [\(a\)*], but [matched_group 1 ""] will raise [Not_found] because the first group itself was not matched. @@@@@@@3M@@@z.@@@@@@C/group_beginning 12@б@г#int<=@@ @@@3>>>>>>>>@\q8@A@@г#intKL@@ @@@@@@@@@@@V @  [group_beginning n] returns the position of the first character of the substring that was matched by the [n]th group of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). @raise Not_found if the [n]th group of the regular expression was not matched. @raise Invalid_argument if there are fewer than [n] groups in the regular expression. cd  @@@@@@@|N@@@w@@@@@@1)group_end!z  {  @б@гY#int    @@ @@@3@J_8@A@@гh#int    @@ @@@@@@@@@@@   @  [group_end n] returns the position of the character following the last character of substring that was matched by the [n]th group of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). @raise Not_found if the [n]th group of the regular expression was not matched. @raise Invalid_argument if there are fewer than [n] groups in the regular expression.   ""@@@@@@@O@@@ @@@@@@1͐1 {1 Replacement} """"@@@@@@3@CX1@A.global_replace"""""@б@гC®exp""""@@ @@@@@б@г&string"#"#@@ @@@)@@б@гʠ&string"# "#@@ @@@8@@гנ&string "# "#@@ @@@E@@@@@H@@@%@@K( @@@7@@N:@@@""@z  [global_replace regexp templ s] returns a string identical to [s], except that all substrings of [s] that match [regexp] have been replaced by [templ]. The replacement template [templ] can contain [\1], [\2], etc; these sequences will be replaced by the text matched by the corresponding group in the regular expression. [\0] stands for the text matched by the whole regular expression. *##+$m$@@@@@@@CP@@!@>@@@@@@m-replace_first#A$$B$$@б@г®expL$$M$$@@ @@@3NNNNNNNN@8@A@@б@г(&string]$$^$$@@ @@@@@б@г7&stringl$$m$$@@ @@@ @@гD&stringy$$z$$@@ @@@-@@@@@0@@@%@@3( @@@9@@6<@@@$$@琠 u Same as {!Str.global_replace}, except that only the first substring matching the regular expression is replaced. $$%7%i@@@@@@@Q@@!@@@@@@@U1global_substitute$%k%o%k%@б@г®exp%k%%k%@@ @@@3@n8@A@@б@б@г&string%k%%k%@@ @@@@@г&string%k%%k%@@ @@@ @@@@@#@@б@г&string%k%%k%@@ @@@2@@гà&string%k%%k%@@ @@@?@@@@@B@@@$@@E%k% @@@L@@IO@@@ %k%k@g / [global_substitute regexp subst s] returns a string identical to [s], except that all substrings of [s] that match [regexp] have been replaced by the result of function [subst]. The function [subst] is called once for each matching substring, and receives [s] (the whole text) as argument. %%&&@@@@@@@0R@@"@w+@@@@@@h0substitute_first%.&&/&&@б@г®exp9&':&'@@ @@@3;;;;;;;;@8@A@@б@б@г&stringL&' M&'@@ @@@@@г$&stringY&'Z&'@@ @@@ @@@@@#@@б@г6&stringk&'!l&''@@ @@@2@@гC&stringx&'+y&'1@@ @@@?@@@@@B@@@$@@E&'  @@@L@@IO@@@&&@琠 x Same as {!Str.global_substitute}, except that only the first substring matching the regular expression is replaced. '2'2'}'@@@@@@@S@@"@@@@@@@h/replace_matched&''''@б@г&string''''@@ @@@3@8@A@@б@г&string''''@@ @@@@@г&string''''@@ @@@@@@@@!@@@'@@$* @@@''@B  [replace_matched repl s] returns the replacement text [repl] in which [\1], [\2], etc. have been replaced by the text matched by the corresponding groups in the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). [s] must be the same string that was passed to the matching or searching function. '')W)p@@@@@@@ T@@@R @@@@@@C  / {1 Splitting}  )s)s )s)@@@@@@3        @Uj1@A%split' )) ))@б@г®exp ')) ())@@ @@@@@б@г &string 6)) 7))@@ @@@)@@г $list C)) D))@г &string M)) N))@@ @@@@@@@@@@E @@@"@@H%@@@4@@ K7@@@ `))@ 7 [split r s] splits [s] into substrings, taking as delimiters the substrings that match [r], and returns the list of substrings. For instance, [split (regexp "[ \t]+") s] splits [s] into blank-separated words. An occurrence of the delimiter at the beginning or at the end of the string is ignored.  m)) n**@@@@@@@ U@@-@ @@@@@@j-bounded_split( ** *+@б@г®exp *+ *+@@ @@@ 3        @~8@A@@б@г k&string *+ *+@@ @@@ @@б@г #int *+ *+@@ @@@  @@г ;$list *+* *+.@г &string *+# *+)@@ @@@ 7@@@@@@< @@@"@@?%@@@4@@B7@@@H@@EK@@@ ** @9 l Same as {!Str.split}, but splits into at most [n] substrings, where [n] is the extra integer parameter.  +/+/ +q+@@@@@@@ V@@0@I @@@@@@d+split_delim) ++ ++@б@гm®exp ++ ++@@ @@@3        @}8@A@@б@г 砐&string ++ ++@@ @@@@@г $list )++ *++@г &string 3++ 4++@@ @@@(@@@@@@- @@@"@@0%@@@6@@39@@@ F++@ 5 Same as {!Str.split} but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result. For instance, [split_delim (regexp " ") " abc "] returns [[""; "abc"; ""]], while [split] with the same arguments returns [["abc"]].  S++ T,-@@@@@@@ lW@@-@ g@@@@@@R3bounded_split_delim* j-- k--'@б@гנ®exp u--* v--0@@ @@@3 w w w w w w w w@k8@A@@б@г Q&string --4 --:@@ @@@@@б@г i#int --> --A@@ @@@ @@г !$list --L --P@г w&string --E --K@@ @@@7@@@@@@< @@@"@@ ?%@@@4@@!B7@@@H@@"EK@@@ -- @  Same as {!Str.bounded_split}, but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result.  -Q-Q -.@@@@@@@ X@@0@ / 㐠@@@@@@dA+,split_result+B ..  ..@@;@@$Text, @@@#@@  ..   ...@@ Z@%Delim- @@@$@@  ./.1  ./.B@@ [@@@A@@@@@ ..@@@@ Y@@#    ..$@@г!&string  ..("@@(3        @\9;@@@A@@@@@@@@@A(@@@@*@#&& # ./.3 $ ./.8@@г(&string - ./.<)@@/*@@@@,@@A@(@@3 , , , , , , , ,@@A),@*full_split. 9 .D.H : .D.R@б@г ®exp D .D.U E .D.[@@ @@@.3 F F F F F F F F@0hb@A@@б@г &string U .D._ V .D.e@@ @@@/@@г ᠐$list b .D.v c .D.z@г,split_result l .D.i m .D.u@@ @@@0(@@@@@@2- @@@"@@30%@@@6@@439@@@  .D.D@ ܐ 0 Same as {!Str.split_delim}, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged [Delim] in the result list; the latter are tagged [Text]. For instance, [full_split (regexp "[{}]") "{ab}"] returns [[Delim "{"; Text "ab"; Delim "}"]].   .{.{ //@@@@@@@ \@@-@  @@@@@@R2bounded_full_split/ // //@б@г ®exp // //@@ @@@53        @k8@A@@б@г &string // //@@ @@@6@@б@г #int // //@@ @@@7 @@г Z$list // //@г,split_result // //@@ @@@87@@@@@@:< @@@"@@;?%@@@4@@<B7@@@H@@=EK@@@ // @ X Same as {!Str.bounded_split_delim}, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged [Delim] in the result list; the latter are tagged [Text].  // 00@@@@@@@ !]@@0@ h @@@@@@d * ); {1 Extracting substrings}  &00 '00@@@@@@3 % % % % % % % %@v1@A-string_before0 200 301@б@г &string =01  >01@@ @@@>@@б@г #int L01 M01@@ @@@?)@@г $&string Y01 Z01 @@ @@@@6@@@@@A9@@@%@@B<( @@@ g00@ Đ [string_before s n] returns the substring of all characters of [s] that precede position [n] (excluding the character at position [n]).  t1!1! u!11@@@@@@@ ^@@@  @@@@@@[,string_after1 #11 #11@б@г a&string #11 #11@@ @@@C3        @to8@A@@б@г {#int #11 #11@@ @@@D@@г &string #11 #11@@ @@@E@@@@@F!@@@'@@G$* @@@ #11@  [string_after s n] returns the substring of all characters of [s] that follow position [n] (including the character at position [n]).  $11 &2`2t@@@@@@@ _@@@ / 㐠@@@@@@C+first_chars2 (2v2z (2v2@б@г &string (2v2 (2v2@@ @@@H3        @\q8@A@@б@г ֠#int (2v2 (2v2@@ @@@I@@г ڠ&string (2v2 (2v2@@ @@@J@@@@@K!@@@'@@L$* @@@ (2v2v@ z r [first_chars s n] returns the first [n] characters of [s]. This is the same function as {!Str.string_before}.  *)22 +*23@@@@@@@ C`@@@  >@@@@@@C*last_chars3 A,33 B,33'@б@г &string L,33* M,330@@ @@@M3 N N N N N N N N@\q8@A@@б@г 1#int ],334 ^,337@@ @@@N@@г 5&string j,33; k,33A@@ @@@O@@@@@P!@@@'@@Q$* @@@ x,33@ Ր : [last_chars s n] returns the last [n] characters of [s].  -3B3B -3B3@@@@@@@ a@@@  @@@@@@C@  A@  @  e@ E @  @  @ ] @  @  >@ @@lE@%@@^@>@@{0@@4@@b@B@@`@A@M@-@i@I@@^@@3        @`@A@ H************************************************************************ A@@ A@L@ H  BMM BM@ H OCaml  C C@ H  D D3@ H Xavier Leroy, projet Cristal, INRIA Rocquencourt  E44 E4@ H  F F@ H Copyright 1996 Institut National de Recherche en Informatique et  G G@ H en Automatique. HHg@ H  Ihh Ih@ H All rights reserved. This file is distributed under the terms of JJ@ H the GNU Lesser General Public License version 2.1, with the KKN@ H special exception on linking described in the file LICENSE. LOOLO@ H "M#M@ H************************************************************************(N)N5@ 7* Regular expressions and high-level string processing .:* {1 Regular expressions}  * The {!Str} library provides regular expressions on sequences of bytes. It is, in general, unsuitable to match Unicode characters.  ,* The type of compiled regular expressions.  * Compile a regular expression. The following constructs are recognized: - [. ] Matches any character except newline. - [* ] (postfix) Matches the preceding expression zero, one or several times - [+ ] (postfix) Matches the preceding expression one or several times - [? ] (postfix) Matches the preceding expression once or not at all - [[..] ] Character set. Ranges are denoted with [-], as in [[a-z]]. An initial [^], as in [[^0-9]], complements the set. To include a [\]] character in a set, make it the first character of the set. To include a [-] character in a set, make it the first or the last character of the set. - [^ ] Matches at beginning of line: either at the beginning of the matched string, or just after a '\n' character. - [$ ] Matches at end of line: either at the end of the matched string, or just before a '\n' character. - [\| ] (infix) Alternative between two expressions. - [\(..\)] Grouping and naming of the enclosed expression. - [\1 ] The text matched by the first [\(...\)] expression ([\2] for the second expression, and so on up to [\9]). - [\b ] Matches word boundaries. - [\ ] Quotes special characters. The special characters are [$^\.*+?[]]. In regular expressions you will often use backslash characters; it's easier to use a quoted string literal [{|...|}] to avoid having to escape backslashes. For example, the following expression: {[ let r = Str.regexp {|hello \([A-Za-z]+\)|} in Str.replace_first r {|\1|} "hello world" ]} returns the string ["world"]. If you want a regular expression that matches a literal backslash character, you need to double it: [Str.regexp {|\\|}]. You can use regular string literals ["..."] too, however you will have to escape backslashes. The example above can be rewritten with a regular string literal as: {[ let r = Str.regexp "hello \\([A-Za-z]+\\)" in Str.replace_first r "\\1" "hello world" ]} And the regular expression for matching a backslash becomes a quadruple backslash: [Str.regexp "\\\\"].  ? * Same as [regexp], but the compiled expression will match text in a case-insensitive way: uppercase and lowercase letters will be considered equivalent.  V* [Str.quote s] returns a regexp string that matches exactly [s] and nothing else.  b* [Str.regexp_string s] returns a regular expression that matches exactly [s] and nothing else. m y* [Str.regexp_string_case_fold] is similar to {!Str.regexp_string}, but the regexp matches in a case-insensitive way.  ' $* {1 String matching and searching}  * [string_match r s start] tests whether a substring of [s] that starts at position [start] matches the regular expression [r]. The first character of a string has position [0], as usual.  :* [search_forward r s start] searches the string [s] for a substring matching the regular expression [r]. The search starts at position [start] and proceeds towards the end of the string. Return the position of the first character of the matched substring. @raise Not_found if no substring matches.  E U* [search_backward r s last] searches the string [s] for a substring matching the regular expression [r]. The search first considers substrings that start at position [last] and proceeds towards the beginning of string. Return the position of the first character of the matched substring. @raise Not_found if no substring matches.  ۠ * Similar to {!Str.string_match}, but also returns true if the argument string is a prefix of a string that matches. This includes the case of a true complete match.  q * [matched_string s] returns the substring of [s] that was matched by the last call to one of the following matching or searching functions: - {!Str.string_match} - {!Str.search_forward} - {!Str.search_backward} - {!Str.string_partial_match} - {!Str.global_substitute} - {!Str.substitute_first} provided that none of the following functions was called in between: - {!Str.global_replace} - {!Str.replace_first} - {!Str.split} - {!Str.bounded_split} - {!Str.split_delim} - {!Str.bounded_split_delim} - {!Str.full_split} - {!Str.bounded_full_split} Note: in the case of [global_substitute] and [substitute_first], a call to [matched_string] is only valid within the [subst] argument, not after [global_substitute] or [substitute_first] returns. The user must make sure that the parameter [s] is the same string that was passed to the matching or searching function.  + * [match_beginning()] returns the position of the first character of the substring that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). 堠 * [match_end()] returns the position of the character following the last character of the substring that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details).  * [matched_group n s] returns the substring of [s] that was matched by the [n]th group [\(...\)] of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). When [n] is [0], it returns the substring matched by the whole regular expression. The user must make sure that the parameter [s] is the same string that was passed to the matching or searching function. @raise Not_found if the [n]th group of the regular expression was not matched. This can happen with groups inside alternatives [\|], options [?] or repetitions [*]. For instance, the empty string will match [\(a\)*], but [matched_group 1 ""] will raise [Not_found] because the first group itself was not matched. G * [group_beginning n] returns the position of the first character of the substring that was matched by the [n]th group of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). @raise Not_found if the [n]th group of the regular expression was not matched. @raise Invalid_argument if there are fewer than [n] groups in the regular expression.  * [group_end n] returns the position of the character following the last character of substring that was matched by the [n]th group of the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). @raise Not_found if the [n]th group of the regular expression was not matched. @raise Invalid_argument if there are fewer than [n] groups in the regular expression. 2* {1 Replacement}  * [global_replace regexp templ s] returns a string identical to [s], except that all substrings of [s] that match [regexp] have been replaced by [templ]. The replacement template [templ] can contain [\1], [\2], etc; these sequences will be replaced by the text matched by the corresponding group in the regular expression. [\0] stands for the text matched by the whole regular expression. C v* Same as {!Str.global_replace}, except that only the first substring matching the regular expression is replaced. ٠ 0* [global_substitute regexp subst s] returns a string identical to [s], except that all substrings of [s] that match [regexp] have been replaced by the result of function [subst]. The function [subst] is called once for each matching substring, and receives [s] (the whole text) as argument. \ y* Same as {!Str.global_substitute}, except that only the first substring matching the regular expression is replaced. ߠ * [replace_matched repl s] returns the replacement text [repl] in which [\1], [\2], etc. have been replaced by the text matched by the corresponding groups in the regular expression that was matched by the last call to a matching or searching function (see {!Str.matched_string} for details). [s] must be the same string that was passed to the matching or searching function. 0* {1 Splitting} l 8* [split r s] splits [s] into substrings, taking as delimiters the substrings that match [r], and returns the list of substrings. For instance, [split (regexp "[ \t]+") s] splits [s] into blank-separated words. An occurrence of the delimiter at the beginning or at the end of the string is ignored.  m* Same as {!Str.split}, but splits into at most [n] substrings, where [n] is the extra integer parameter.  6* Same as {!Str.split} but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result. For instance, [split_delim (regexp " ") " abc "] returns [[""; "abc"; ""]], while [split] with the same arguments returns [["abc"]]. 2 * Same as {!Str.bounded_split}, but occurrences of the delimiter at the beginning and at the end of the string are recognized and returned as empty strings in the result.  1* Same as {!Str.split_delim}, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged [Delim] in the result list; the latter are tagged [Text]. For instance, [full_split (regexp "[{}]") "{ab}"] returns [[Delim "{"; Text "ab"; Delim "}"]].  * Same as {!Str.bounded_split_delim}, but returns the delimiters as well as the substrings contained between delimiters. The former are tagged [Delim] in the result list; the latter are tagged [Text]. <* {1 Extracting substrings} k * [string_before s n] returns the substring of all characters of [s] that precede position [n] (excluding the character at position [n]).  * [string_after s n] returns the substring of all characters of [s] that follow position [n] (including the character at position [n]). Ƞ s* [first_chars s n] returns the first [n] characters of [s]. This is the same function as {!Str.string_before}. p ;* [last_chars s n] returns the last [n] characters of [s]. @?0../../ocamlc.opt)-nostdlib"-I,../../stdlib"-c(-absname"-w5+a-4-9-41-42-44-45-48+-warn-error"+A*-bin-annot"-g0-strict-sequence/-strict-formats X/home/ci/builds/workspace/precheck/flambda/false/label/ocaml-ubuntu-latest/otherlibs/str @@0=N4F-; 3@@@8CamlinternalFormatBasics0%FU(Q/Tu&Stdlib0Lku]8_٠֐0ϭE6h)@0ϭE6h)Ab@  @2@%@H8@@U ؐ @ 8 @@M@@  U Ӑ 1@|@^@@ l @   Z @@  @w ; W@T@"߰ː'@K@ U@@@@@@@ D ~  @ 1 k@@P@@