Hi,
I want to make a simple Lexer
Because out program makes text files which every type of line begins with a character.
The first Line is always beginning with a *
The next lines always begins with |
and the last line begins with _
Can someone explain me how I can color the complete line after those characters.
Frits
Simple Lexer
Regex is much powerful but hard to understand. If you're interested, the link from Alex gives a good start into regex knowledge.
Let me explain the 1st regex. "^\*.*$" represents any line that starts with a star "*". now take a closer look on every single regex part:
^ - marks the beginning of any line in text
\* - the symbol * is a reserved char in regex, so we need to escape it with a "\". "\*" stands for the character "*" in text.
with "^\*" we have now defined any line that starts with *. but you want to highlight the whole line and not only the * character at line start. so we need some more code
. - stands for any single character (a letter, number, symbol) that follows the *
* - repeat the "." until another condition follows. ".*" together means any text with mixed letters, numbers, symbols
$ - marks the end of line
Let me explain the 1st regex. "^\*.*$" represents any line that starts with a star "*". now take a closer look on every single regex part:
^ - marks the beginning of any line in text
\* - the symbol * is a reserved char in regex, so we need to escape it with a "\". "\*" stands for the character "*" in text.
with "^\*" we have now defined any line that starts with *. but you want to highlight the whole line and not only the * character at line start. so we need some more code
. - stands for any single character (a letter, number, symbol) that follows the *
* - repeat the "." until another condition follows. ".*" together means any text with mixed letters, numbers, symbols
$ - marks the end of line