How do I make a regular expression for all special characeters in OCaml?

How do I make a regular expression for all special characeters in OCaml?

there should be 32 of them.

Your other questions have been about ocamllex and not so much about OCaml itself. So I’ll assume you want to know how to make a pattern in ocamllex that matches any single character with a character code between 0 and 31.

A rule like this should do what you want:

let special = ['\x00' - '\x1f']

Note that this is exactly the same as your rule for digit except that the range of characters is different.

2 Likes