This regex should match any string with arbitrary many ‘a’ characters, and nothing else. Of all the strings checked in _ready() function, regex.search matches “aaa” and “aaa\n”. All others return null. “aaa\n” should also return null. I have an idea of a couple workarounds - for instance, I could just have an additional check to see if a string ends with ‘\n’. However, I’d like to know if there is a correct way of doing this or if I’m missing something obvious.
As far as I know, the $ anchor matches the absolute end of the string OR the position right before a newline at the end of a string, so in most regex engines, saying that “aaa\n” should return null isn’t necessarily a bug, but expected behaviour. But someone should correct me if I’m wrong.
Thank you very much for your reply! It seems that it works exactly as you described it. After some searching and testing, \z should probably be used instead of $ to match the end of the string. In the article that led me to that conclusion (it wasn’t a Godot-related article), they said that not every platform supports \z. Some use \Z, and some don’t recognize either. I am on Linux, so if anyone can test that on Windows, it would be much appreciated. The first line in the _ready() function should be replaced with: