Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Str partial match problem #3534

Closed
vicuna opened this issue Aug 17, 2002 · 2 comments
Closed

Str partial match problem #3534

vicuna opened this issue Aug 17, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 17, 2002

Original bug ID: 1333
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Gene Saunders
Version: 3.05
OS: Windows 2000
Submission from: curie.noos.net (212.198.0.93)

Str.string_partial_match returns true whenever Str.string_match succeeds on a
starting sub-string. This can mask the failure of string_partial_match, making
it impossible to detect a partial match in all cases.

Code example:
(* problem with partial matching of a regular expression *)

#load "str.cma";;

let reg = Str.regexp "a\(bc\)";; ( a, abc, abcbc, ... *)

let test reg str =
str, (Str.string_match reg str 0), Str.match_end (), (Str.string_partial_match
reg str 0);;

(* Both aa and ab return the same results. ab is a partial match but aa is not
*)
test reg "aa";;
test reg "ab";;

    Objective Caml version 3.05

#use "regexp-bug.ml";;

val reg : Str.regexp =
val test : Str.regexp -> string -> string * bool * int * bool =

  • : string * bool * int * bool = ("aa", true, 1, true)
  • : string * bool * int * bool = ("ab", true, 1, true)

@vicuna
Copy link
Author

vicuna commented Aug 19, 2002

Comment author: administrator

Str.string_partial_match returns true whenever Str.string_match
succeeds on a starting sub-string. This can mask the failure of
string_partial_match, making it impossible to detect a partial match
in all cases.

string_partial_match is a weird operation, and will probably be
removed in the future. This said, I'm afraid there is a
misunderstanding on its specification. Basically,

    Str.string_partial_match re txt ofs

succeeds if and only if there exists a string "suff" such that

    Str.string_match re (txt ^ suff) ofs

succeeds.

It follows that string_partial_match will always succeed when
string_match succeeds -- which is the case in your "aa" and "ab"
examples.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Aug 19, 2002

Comment author: administrator

Normal behavior of Str.string_partial_match.

@vicuna vicuna closed this as completed Aug 19, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant