Q:

Lexical analysis: Comments at end of line

I am tokenizing a string such as:

BAS=W34 N29 E24 S29$FOP=E6 S6 W6 N6$. A Comment

The period is the "end of command" character, not a "beginning of comment" character.  How can I add a regular expression rule to the lexer such that the period is a token unto itself, but anything after the period is a token with type COMMENT?  I tried /\..+$/, but that includes the period in the comment.

A:

You might could try 2 ways, a non-capturing group, or a look-behind (which is also non-capturing):
(?:\.).+$

(?<=\.).+$

