I want to construct a regular expression (in the style of lex, with a more OCaml-like syntax) for a class of strings, where 4 characters [
, ]
, #
, '
are allowed only if they are preceded by an escape character '
.
Here are some valid examples:
'#Data
,abc'#Headers
,abc'#Totals'[efg
,123'#Totals']efg
,abc
,123
Here are some non-valid examples:
#Data
,abc#Headers
,abc#Totals[efg
,123#Totals]efg
,'#Totals[efg
Hope the definition is clear. First, does anyone know how to construct such a regular expression? Second, does anyone know how to construct such a regular expression (in the style of lex, with a more OCaml-like syntax) that can be accepted by ocamllex?