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: | Kurt Welgehausen <kaw@k...> |
| 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.
>
> Then they're simply wrong. The fundamental operation is
> to check if a string is in a regular set of strings.
> Plainly 'aa' is not in the set { 'a' }.
Str.string_match is almost exactly the same as Python's
re.match:
# Str.string_match (Str.regexp "a") "ab" 0 ;;
- : bool = true
>>> re.match(re.compile("a"), "ab") #succeeds
<_sre.SRE_Match object at 0x8146f60>
# Str.string_match (Str.regexp "a") "bab" 0 ;;
- : bool = false
>>> re.match(re.compile("a"), "bab") #returns None
>>>
# Str.string_match (Str.regexp "a") "bab" 1 ;;
- : bool = true
>>> re.match(re.compile("a"), "bab"[1: ])
<_sre.SRE_Match object at 0x814c748>
>>> #Python has no parameter to change the start position
Regards