Personally, I would use Regex, I use: https://regexr.com/ as my cheat sheat.
Definately read: Strings | Documentation - Roblox Creator Hub
I don’t know of any way to implement the studio way of syntax but you could just use regex to change the color of text based on the words and format.
Syntax highlight is often more complex than it seems. Its more than just a simple string matching algorithm and would likely involve some form of code compilation. You could use purely string matching to make a basic syntax highlight like @jackthefur mentioned. If it is Lua code that you wish to syntax highlight, you could look for matches on common key words like local, function, end, etc. If you’d like to learn more about compilers and compiling then some concepts to look into include scanning, parsing, semantic analysis, finite state autonoma, regular expressions, and context free grammars, as a start .