Browse thread
Str.string_match incorrect
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | William Lovas <wlovas@s...> |
| Subject: | Re: [Caml-list] Str.string_match incorrect |
On Tue, Dec 21, 2004 at 11:44:55PM -0800, Evan Martin wrote:
> This is consistent with the docs, which say:
> [string_match r s start] tests whether the characters in s starting at
> position start match the regular expression r.
> and in general with how regular expression systems work. string_match
> corresponds to running your automaton directly and seeing whether you
> end up in an accept state, while string_partial_match effectively adds
> an extra ".*" to the beginning.
> (It's more debatable whether this makes sense.)
I concur with your assessment, but i think you're characterization of the
semantics of string_partial_match is inaccurate:
# Str.string_match (Str.regexp "ab") "a" 0;;
- : bool = false
# Str.string_partial_match (Str.regexp "ab") "a" 0;;
- : bool = true
# Str.string_match (Str.regexp ".*ab") "a" 0;;
- : bool = false
... unless of course, i've misunderstood you. I don't think there's a
simple transformation on regular expressions that allow you to emulate
string_partial_match's behavior using only string_match. (Does anyone
care to prove me wrong? :)
cheers,
William