How do i check if this is a full word?

So, I am making a luau syntax highlighter using RichText and gsub.
Works well, but when another word is in another, they interfere.

Example:
local inside = "hi"
The “in” in “inside” is flagged as something that needs to be highlighted, and I only want it to be highlighted if It’s by itself.

Help would be very much appreciated!

1 Like

Use regex to match the start and end of strings in Lua, that would be the characters ^ to represent the start of a string of characters and $ to match the end of a string of characters.

1 Like

What is regex? Also, can you show an example of what you mean?

1 Like

Regex is short for regular expressions, an advanced pattern matching system. There are resources online for it, and you will need to learn it to have any hope of making syntax highlighting.

1 Like

You could just save yourself some time and use an already-made Lexer for Lua.

1 Like

Found it out, %[a] seems to work.
Thanks for your help anyways!

1 Like