<?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/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"
  prev="2002/07/72c2dc79654035cd9f28bd2d5e20f330"
  next="2002/07/9a687ad070011724873fe56086b999a8"
  prev-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:

[...]

&gt; Feature 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.
&gt;
&gt;      has already used           0
&gt;      could use in some cases    6
&gt;      no use                     8

[...]

&gt; Feature 2 is unusual and I haven't heard from anyone that uses it
&gt; :-) I got two replies suggesting one plausible scenario where
&gt; partial matching could come handy: find delimiters in a piece of
&gt; text that is being read block by block.  However, I'm not sure
&gt; Str.string_partial_match is adequate here, it looks like a "search
&gt; forward for a partial match" operation is needed, which Str doesn't
&gt; provide...

This is how a MIME message parser I wrote worked (written in a
scripting language that made byte-by-byte string comparisons more
costly than regexps).  The parser read in the message chunk by chunk.
I had a list of regexps representing the current set of MIME
boundaries, and I was interested if the last N bytes of the current
chunk ended with a (possibly partial) match of each regexp.  If there
was a match and it wasn't complete, you have to deal with a MIME
boundary that might cross a chunk boundary.


&gt; It was also suggested to me that the effect of partial matching
&gt; against a regexp R can be achieved by exact matching against a
&gt; regexp R' derived from R.  This is true for "textbook regexps",
&gt; e.g. if R is "ab*c", then R' would be
&gt; "epsilon|a(epsilon|b*(epsilon|c))", but doesn't work for more
&gt; complex regexps languages, especially if back-references are
&gt; supported.  (Consider R = "(a+)\1".)

And in the MIME parser, this is what I did -- since the regexps were
simple.

In Ocaml, I'm not sure I would use regexps for this at all since (I
assume) comparing strings "by hand" would be fast.
-------------------
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>

