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

Re: Regexp-problem, why do all but the first fail? Shouldn't those regexp match? (PR#428) #2832

Closed
vicuna opened this issue Jul 10, 2001 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 10, 2001

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

Bug description

mattias.waldau@abc.se a écrit :

    Objective Caml version 3.01

Str.search_forward (Str.regexp_string "a") "a" 0;;

  • : int = 0

Str.search_forward (Str.regexp_string "a*") "a" 0;;

Uncaught exception: Not_found.

Str.search_forward (Str.regexp_string "[a-z]*") "a" 0;;

Uncaught exception: Not_found.

Str.search_forward (Str.regexp_string "[a-z]+") "a" 0;;

Uncaught exception: Not_found.

Str.search_forward (Str.regexp_string "a+") "a" 0;;

Uncaught exception: Not_found.

I think that using Str.regexp rather than Str.regexp_string will what
you expected.
Str.regexp_string creates a reg. exp. matching exactly the given string.
Str.regexp creates a reg. exp. as you defined in the string in
parameter.

    Objective Caml version 3.01

Str.search_forward (Str.regexp "a") "a" 0;;

  • : int = 0

Str.search_forward (Str.regexp "a*") "a" 0;;

  • : int = 0

Str.search_forward (Str.regexp "[a-z]*") "a" 0;;

  • : int = 0

Str.search_forward (Str.regexp "[a-z]+") "a" 0;;

  • : int = 0

Str.search_forward (Str.regexp "a+") "a" 0;;

  • : int = 0

--
Maxence Guesdon

@vicuna
Copy link
Author

vicuna commented Jul 10, 2001

Comment author: administrator

Reply to #2831

@vicuna vicuna closed this as completed Jul 10, 2001
@vicuna vicuna added the bug label Mar 19, 2019
ulrikstrid pushed a commit to ulrikstrid/ocaml that referenced this issue Sep 17, 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