YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
22 stars 8 forks source link

Regular expression match/search/replace support (both in IDE and in game) #3237

Open biyectivo opened 1 year ago

biyectivo commented 1 year ago

Is your feature request related to a problem?

Code (in-game) regex support: The problem is having to fumble with multiple string functions and cases when trying to do non-trivial parsing, matching and substitution of parts of strings efficiently.

IDE search/replace regex support: When searching large projects with global find/replace, it would greatly help to have the regex power to find more specific stuff.

Describe the solution you'd like

Code (in-game) regex support: I would implement a basic subset of what Python provides in the re package (https://docs.python.org/3/library/re.html):

IDE search/replace regex support: I love the way Notepad++ provides this, I would copy it, it allows for a basic text search/replace, an extended search/replace (being able to specify control characters) or a full-fledged regex search/replace:

image

Describe alternatives you've considered

Code: I've resorted to using a combination of available string functions, if statements and many other horrible hacks. I've also created a package that uses Samuel Venable's Execute Shell (libxprocess) to summon a compiled EXE program for each of the aforementioned functions, created in Python with re, on the background, sending it an input string and getting the result back to GM, but obviously this is horrendous per se, badly performing and not suitable for production projects.

IDE: if within a single script/object event/etc., I copy-paste the contents to Notepad++, perform the search (or search/replace) in Notepad++ then return it back to GM, which is horrible but works.

Additional context

Code: Nearly all modern languages have regex implemented. IDE: VSCode, Notepad++ and many other editors support this.

Alphish commented 1 year ago

I generally agree it would be good to get some regular expressions functionality in GameMaker. When it comes to naming the new functions, I'd suggest just using regex_* instead of string_regex_*, since there are no built-in functions that could be mistaken for regex, anyway.

Mortisanti commented 1 year ago

This would be so useful. I've been wanting it for a long time.

yunzlp commented 1 year ago

And string.match