Don't do it like that: it's far, far too easy to have "false positives":
MAKE_LETTER("QUIFF")
for example will match your:
if (s1.Contains("IF"))
and that'll throw everything out.
Instead, consider writing a
tokenizer[
^] and processing the user code as a stream of tokens. There are a fair number of lexical processors out there:
Google[
^] will show you a couple of hundred on this site alone. I'd have a look at some of those articles (though they can get pretty heavy for a beginner) and see what they are doing, why they are doing it, and maybe how they are doing it before going any further.
A simplistic approach like you current one will just end up with more, and more special cases as you process more and more complex code - and will quickly become unreliable and unmaintainable! It's worth thinking about "doing it properly" right from the start, as it'll save you a lot of time and heartache later - the more time and effort you invest in the simplistic approach, the harder it is so say "Sod it! this won't work" and throw it away. That's still one of the things I find hardest to do: bin code I've worked hard on because it clearly isn't going to do what I want without major faffing about. And I've been doing this for decades! :laugh: