* regexp bug?
@ 2005-05-04 2:46 Eliot Handelman
2005-05-03 23:56 ` [Caml-list] " Hal Daume III
2005-05-04 2:31 ` Jason Hickey
0 siblings, 2 replies; 4+ messages in thread
From: Eliot Handelman @ 2005-05-04 2:46 UTC (permalink / raw)
To: caml
This doesn't seem right:
Objective Caml version 3.08.0
open Str
let search r str =
search_forward (regexp r) str 0;
matched_string str;;
# search "[aA-zZ]+" "_test";;
- : string = "_test"
whereas:
# search "[a-zA-Z]+" "_test";;
- : string = "test"
-- eliot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] regexp bug?
2005-05-04 2:46 regexp bug? Eliot Handelman
@ 2005-05-03 23:56 ` Hal Daume III
2005-05-04 5:48 ` Eliot Handelman
2005-05-04 2:31 ` Jason Hickey
1 sibling, 1 reply; 4+ messages in thread
From: Hal Daume III @ 2005-05-03 23:56 UTC (permalink / raw)
To: Eliot Handelman; +Cc: caml
Why not? ord('_') is 95, which is between ord('A') = 65 and ord('z'),
which is 122. OTOH, it is not between ord('A') = 65 and ord('Z') = 90 OR
ord('a') = 97 and ord('z') = 122.
the first regexp matches anything in the set
{a} union {Z} union {everything between A and z}
while the second matches anything in the set
{everything between a and z} union {everything between A and Z}
On Tue, 3 May 2005, Eliot Handelman wrote:
> This doesn't seem right:
>
>
> Objective Caml version 3.08.0
> open Str
>
> let search r str =
> search_forward (regexp r) str 0;
> matched_string str;;
>
> # search "[aA-zZ]+" "_test";;
> - : string = "_test"
>
> whereas:
>
> # search "[a-zA-Z]+" "_test";;
> - : string = "test"
>
>
> -- eliot
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Hal Daume III | hdaume@isi.edu
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] regexp bug?
2005-05-04 2:46 regexp bug? Eliot Handelman
2005-05-03 23:56 ` [Caml-list] " Hal Daume III
@ 2005-05-04 2:31 ` Jason Hickey
1 sibling, 0 replies; 4+ messages in thread
From: Jason Hickey @ 2005-05-04 2:31 UTC (permalink / raw)
To: eliot; +Cc: caml
You may wish to visit, for example, the egrep(1) man page for a
description of regular expressions. Note that the [a-zA-Z] and [aA-zZ]
regular expressions are different. The former contains the alphabetic
characters. The latter is equivalent to [A-z], which in ASCII also
contains several other characters between 'A' and 'z', including '_'.
Jason
Eliot Handelman wrote:
> This doesn't seem right:
>
>
> Objective Caml version 3.08.0
> open Str
>
> let search r str =
> search_forward (regexp r) str 0;
> matched_string str;;
>
> # search "[aA-zZ]+" "_test";;
> - : string = "_test"
>
> whereas:
>
> # search "[a-zA-Z]+" "_test";;
> - : string = "test"
>
>
> -- eliot
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
--
Jason Hickey http://www.cs.caltech.edu/~jyh
Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-04 2:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-04 2:46 regexp bug? Eliot Handelman
2005-05-03 23:56 ` [Caml-list] " Hal Daume III
2005-05-04 5:48 ` Eliot Handelman
2005-05-04 2:31 ` Jason Hickey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox