• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Will there be RegEx?

Will there be RegEx with GMS2?
Well even though we have market assets for that, it would be nice to have that feature added to the
functions, and maybe it wouldn't be to difficult... I just ask this because it would be perfect to have something
that works across all platforms.. I already own some RegEx assets from marketplace and yet I think it is something worth looking at.

Can someone from the crew give some lights ;) (a green one, just kidding... would be great though) :D

PS: I know that IDE fixes must be the main concern right now, but it was worth the try :)
 

Mike

nobody important
GMC Elder
Personally.... I never see the need for them in games, so it wouldn't be high on my list of additions.
 
I just said, because if I need to process a command... inside a text...
not only to match but to extract commands and arguments
the text is matched... and is returned... maybe not all games will have this... but for example.. text based games...
sure would have a boost in development speed...

Thank you for you time,

Personally.... I never see the need for them in games, so it wouldn't be high on my list of additions.
Not wanting to be rude and sorry (really), I don't usually ask for features... and this is not a "change the way GameMaker works thing"
 
Last edited by a moderator:

gnysek

Member
I just said, because if I need to process a command... inside a text...
not only to match but to extract commands and arguments
the text is matched... and is returned... maybe not all games will have this... but for example.. text based games...
sure would have a boost in development speed...

Thank you for you time,

https://gnysek.github.io/ConsoleDemo/index.html - I've made a console example with arguments, and it works without regex.
You can buy it there: https://marketplace.yoyogames.com/assets/2444/in-game-console
 
https://gnysek.github.io/ConsoleDemo/index.html - I've made a console example with arguments, and it works without regex.
You can buy it there: https://marketplace.yoyogames.com/assets/2444/in-game-console
well, I give up... it's useless... I said it would be easier to implement... not that it would be the ONLY solution... as far as I know you don't need a graphical IDE to make a game.. you can open a terminal and do everything there... but it is easier to do it in a graphical IDE... sorry if I'm being rude.
 

Mike

nobody important
GMC Elder
I have to say... I've also done a full command parser, and it's not a lot of code. Simpler commands like string_split( ) would be much more useful, but doing it yourself isn't hard, and RegEx is a pain to write and maintain.

If you look at the link @gnysek pointed at, and click preview, you can see it's not a lot of code/script. It's a pretty simple issue.

Sorry...
 
Personally.... I never see the need for them in games, so it wouldn't be high on my list of additions
faster/easier string manipulation
client side UI/form validation
tokenizers
custom file format parsers

RegEx is a pain to write and maintain
Isn't RegEx standard in C#, JS and C++ 11 now anyway?
https://www.solarianprogrammer.com/2011/10/12/cpp-11-regex-tutorial/ C++11
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx C#
https://developer.apple.com/reference/foundation/nsregularexpression Objective-C
https://developer.android.com/reference/java/util/regex/package-summary.html Java
https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions JS

So you wouldn't really have to maintain much, just use the provided functions per platform/language

there is a regex asset on the marketplace already...
None of them are truly crossplatform though
 
Last edited:

icuurd12b42

TMC Founder
GMC Elder
Hmm there are various regex sources in various languages that could be ported to gml... But since gml is a language with it's own limits, the translation would be tedious...
 

Jobo

Member
GMC Elder
faster/easier string manipulation
Something you really don't do much of in games... Usually it's with known quantities, so a regex wouldn't be necessary anyway.

client side UI/form validation
This is really the only strong use case for regexes in games, and this is also the reason I made a regex asset available for Android, iOS and Windows: https://marketplace.yoyogames.com/assets/572/regular-expressions-bundle

tokenizers
This is not applicable to games...

custom file format parsers
You shouldn't be using regexes to parse.... well, anything, really, I would say. Only for simple pattern recognition.

None of them are truly crossplatform though
Surely having regexes for Android/iOS/Windows is a lot better than none of them? It also makes it a lot cheaper if you do need the rest of the platforms, because 3 of them have been covered for you already...
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Splitting commands is all pretty trivial actually,
Code:
var str = "/say hi"; // input
var pos = string_pos(" ", str);
var cmd, arg;
if (pos > 0) {
    cmd = string_copy(str, 1, pos - 1);
    arg = string_delete(str, 1, pos);
} else {
    cmd = str;
    arg = "";
}
(live example)

Regular expressions are an interesting thing,
For common small use cases (input validation, string parsing, etc.) using a custom script is going to be both faster (as it will be compiled rather than needing to be parsed-interpreted at runtime) and with a smaller footprint. The convenient part is that
While there are certain "average-scale" use cases where a regular expressions are going to be an easier option, they all are related to advanced text processing and are not something that happens in vast majority of games.
For "large-scale" use cases such as parsers or tokenizers it is almost never beneficial to use regular expressions as instead of a O(1..3) switch on the current character you force the program to do O(N) calls to regular expression matcher with each of possible patterns. These are also very uncommon in games themselves.

Therefore it makes perfect sense to keep such functionality optional and in form of extension(s). While having an official extension for this would be more convenient, I'm sure that user-created extensions for currently-missing platforms would appear given sufficient demand or could be commissioned given sufficient need.
 
Splitting commands is all pretty trivial actually,
Code:
var str = "/say hi"; // input
var pos = string_pos(" ", str);
var cmd, arg;
if (pos > 0) {
    cmd = string_copy(str, 1, pos - 1);
    arg = string_delete(str, 1, pos);
} else {
    cmd = str;
    arg = "";
}
(live example)

Regular expressions are an interesting thing,
For common small use cases (input validation, string parsing, etc.) using a custom script is going to be both faster (as it will be compiled rather than needing to be parsed-interpreted at runtime) and with a smaller footprint. The convenient part is that
While there are certain "average-scale" use cases where a regular expressions are going to be an easier option, they all are related to advanced text processing and are not something that happens in vast majority of games.
For "large-scale" use cases such as parsers or tokenizers it is almost never beneficial to use regular expressions as instead of a O(1..3) switch on the current character you force the program to do O(N) calls to regular expression matcher with each of possible patterns. These are also very uncommon in games themselves.

Therefore it makes perfect sense to keep such functionality optional and in form of extension(s). While having an official extension for this would be more convenient, I'm sure that user-created extensions for currently-missing platforms would appear given sufficient demand or could be commissioned given sufficient need.
What if the input is not like that?
what if it is something like a scripting language?!

"something here and there /now(bla, bla) this is a command with arguments and other things /later this is a command without arguments this // is not a command.. and/earlier this is a command with no spaces before the command, and /future(bla)is a command with no spaces after"

this input is not so easier to process as said before... well, I created the topic and I already gave up my suggestion... --' each one of you want the features they need... so its just obvious that... if you don't need it... then it's not important xD well...

It was a suggestion and the answer was a no... so I really would like for the admin to close the topic! please! ;)
 
Last edited:
Top