Search code examples
regexerlangleex

How to match the beginning of a line in leex?


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?


Solution

  • 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.