How to match the beginning of a line in leex?

322 views Asked by At

According to the leex documentation

^ Matches the beginning of a string.

But when I try to use it in a pattern such as ^[^\s\t-:]+[^:].*$ I get this error: bad regexp 'illegal character ^'

Is there a better way to match the begging of a line | string in leex?

2

There are 2 answers

2
johlo On BEST ANSWER

At the end of the documentation page you find this note:

Anchoring a regular expression with ^ and $ is not implemented in the current version of Leex and just generates a parse error.

Which seems to mean you can't use ^ and $ with a regexp in between like you do.

If you know the strings end with a specific character (like \n) I assume you can replace the $ with that char delimiter instead.

0
SkyNet On

(Yes, leex does not support an anchor token '^'). You need to use \A anchor instead