<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/e4e76a2c52e44966440773a9035b784d"
  from="Pixel &lt;pixel@m...&gt;"
  author="Pixel"
  date="2002-07-05T15:56:16"
  subject="Re: [Caml-list] Regular expression library: a poll on features"
  prev="2002/07/e1d274a133b68487086df9bb59b11307"
  next="2002/07/d35cfad39ad5a95044585490bdc86185"
  prev-in-thread="2002/07/e8cfed320dd386bfa41ec4a2c3085837"
  next-in-thread="2002/07/8e619ecadafd4f0b69b5f999e24d6c03"
  prev-thread="2002/07/a8750e6e5c21abd91d03e3547ae8f043"
  next-thread="2002/07/1b99bcd01eb69ed9996ff372f98a9f8f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Regular expression library: a poll on features">
<msg 
  url="2002/07/e8cfed320dd386bfa41ec4a2c3085837"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T14:13:04"
  subject="[Caml-list] Regular expression library: a poll on features">
<msg 
  url="2002/07/e4e76a2c52e44966440773a9035b784d"
  from="Pixel &lt;pixel@m...&gt;"
  author="Pixel"
  date="2002-07-05T15:56:16"
  subject="Re: [Caml-list] Regular expression library: a poll on features">
</msg>
<msg 
  url="2002/07/8e619ecadafd4f0b69b5f999e24d6c03"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-15T15:52:46"
  subject="[Caml-list] Re: Regular expression library: a poll on features">
<msg 
  url="2002/07/2b9b4fa0cd7e7bf77d2e5f5b48ff6c3f"
  from="Matt Armstrong &lt;matt@l...&gt;"
  author="Matt Armstrong"
  date="2002-07-15T18:41:41"
  subject="[Caml-list] Re: Regular expression library: a poll on features">
</msg>
</msg>
</msg>
</thread>

<contents>
Xavier Leroy &lt;xavier.leroy@inria.fr&gt; writes:

(posting on the list cuz of the wishlist below)

&gt; 1- back-references in regexps (e.g. "([a-z]+)\1", meaning any sequence
&gt; of lowercase letters followed by another occurrence of the same sequence);

IMO only usefull in few cases. Could be dropped with no pb.

&gt; 
&gt; 2- partial string matching as per Str.string_partial_match, i.e.
&gt; the ability to recognize that a string is a prefix of a string that
&gt; match a regexp.

quite a surprising feature. I can't imagine an interesting example of
its use.


Here is my wishlist to have regexps easily _usable_
(ie. fill the gap with perl/ruby)

- with compiler support (a la printf's format):

  flags = [ `CASELESS | `MULTILINE | `DOTALL | `EXTENDED | `ANCHORED ]
  m : ?option:flags -&gt; regexp -&gt; string -&gt; string tuple option
  match_all : ?option:flags -&gt; regexp -&gt; string -&gt; string tuple list
  cond_match : ?option:flags -&gt; string -&gt; regexp -&gt; (string tuple -&gt; 'a)
                                       -&gt; regexp -&gt; (string tuple -&gt; 'a)
                                          ...
                                       -&gt; 'a
           (with checking the last regexp is always true unless 'a is unit)
  subst     : string -&gt; regexp -&gt; (string tuple -&gt; string) -&gt; string
  gsubst    : string -&gt; regexp -&gt; (string tuple -&gt; string) -&gt; string
  try_subst : string -&gt; regexp -&gt; (string tuple -&gt; string) -&gt; string option

examples

    match Re.m "(\w+)=(\S+)" s with
    | None -&gt; ...
    | Some(v, val) -&gt; ...
    
    Re.cond_match s
      "^\s*#" (fun() -&gt; None)
      "(\w+)=(\S+)" (fun (v, val) -&gt; Some(v, val))
      "" (fun() -&gt; failwith ("bad line " ^ s))
    
    Re.cond_match s "warning: (.*)" (fun s -&gt; eprintf "a problem occured: %s\n" s)

    Re.subst (Re.subst s "^\s+" (fun() -&gt; "")) "\s+$" (fun() -&gt; "")


- Without compiler support

  flags = [ `CASELESS | `MULTILINE | `DOTALL | `EXTENDED | `ANCHORED ]
  re : string -&gt; regexp
  m : ?option:flags -&gt; regexp -&gt; string -&gt; string list option
  match_all : ?option:flags -&gt; regexp -&gt; string -&gt; string list list
  cond_match : ?option:flags -&gt; string -&gt; (regexp * (string list -&gt; 'a)) list -&gt; 'a
  subst     : string -&gt; regexp -&gt; (string list -&gt; string) -&gt; string
  gsubst    : string -&gt; regexp -&gt; (string list -&gt; string) -&gt; string
  try_subst : string -&gt; regexp -&gt; (string list -&gt; string) -&gt; string option

examples

    match m (re"(\w+)=(\S+)") s with
    | Some [ v ; val ] -&gt; ...
    | _ -&gt; ...
    
    cond_match s [ 
        re"^\s*#", fun() -&gt; None ;
        re"(\w+)=(\S+)", fun (v, val) -&gt; Some(v, val) ;
        re"", fun() -&gt; failwith ("bad line " ^ s) ;
    ]
    
    cond_match s "warning: (.*)" (fun s -&gt; eprintf "a problem occured: %s\n" (hd s))

    subst (subst s (re"^\s+") (fun _ -&gt; "")) (re"\s+$") (fun _ -&gt; "")
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

