jisaacstone
jisaacstone

Reputation: 4284

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?

Upvotes: 4

Views: 321

Answers (2)

SkyNet
SkyNet

Reputation: 21

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

Upvotes: 2

johlo
johlo

Reputation: 5500

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.

Upvotes: 4

Related Questions