Regular Expressions!
planned
Mathieu Robertson-Dégarie
Hello! New to SAMMI and absolutely LOVE IT so far. Not sure if it has been asked in the past, but I made a lot of searches and couldn't find anything about it: Regular Expressions.
Regex is a powerful ally in programming when you need to validate a string (URL, phone number, email address, etc.) and it's kind of a shame SAMMI doesn't support them!
For example, I'm trying to make a trigger for a button that would run the button if the URL is valid YouTube Link (it will fetch the title of the video and send it as a chat message on Twitch).
From my current understanding, you can create a text trigger with wildcards, then obtain the value of said wildcards with the Pull Wildcard command, which is great!
But there are SO MANY WAYS for a YouTube URL to be valid (with or without 'https', with or without 'www', whether it's youtube.com or youtu.be, whether there are other parameters in the URL after the video code, and so on).
An idea would be to create a different trigger for each possibility, but there is just too many of them (and there would be no way to get the proper video code value from the URL as a wildcard, since it wouldn't be the same wildcard position depending on which of the triggers got "called").
A regex would totally solve all of this: you write a 1-line rule that includes all of the possibilities and option, enclosing the desired part (video code) so you can use it later as a pull value or whatever, and then it would work with only one trigger, no matter how the link is structured, as long as it's valid.
That's only one of the many uses for a regex, and considering how powerful and amazing SAMMI already is, I'm actually surprised it doesn't supports regular expressions.
So I would very much like to have a regex support in a future update!
Christina
planned
SebasF
Regex is in our roadmap and we are working towards adding it.
Mathieu Robertson-Dégarie
SebasF: ohhh that's awesome! Thanks a lot! Pretty sure it's hard to say, but do you have any rough ETA?
SebasF
Mathieu Robertson-Dégarie: Hard to say :D But yeah, there is no ETA at the moment because it's not so easy to add. The language used to made SAMMI hasn't regex support builtin. But we there are ways to do it anyway, just need more effort. Rest assure we want to add it too as it will be very useful.
Mathieu Robertson-Dégarie
SebasF: Cool, thanks a lot for your replies. I know this isn't a support page, but since we're here, may I ask if you know of any way to validate a URL with the current state of SAMMI (without regex) while you guys are implementing the real stuff?
I
InteractiveDNA
SebasF: What you guys used to create Sammi? Java?
SebasF
Mathieu Robertson-Dégarie: There are no perfect way. I would just check for youtube.com and youtu.be to check if it's a youtube video and trust my viewers they will paste correct links. But also depends on what you want to do. I don't know how you plan to fetch the title, but maybe doing that you can find if it's a correct youtube video or not. You can ask in our discord with more details.
SebasF
InteractiveDNA: SAMMI is made with GameMaker.
Mathieu Robertson-Dégarie
SebasF: Many thanks again! I'll stop spamming here now. But you guys keep up the awesome work! This app is amazing!
I
InteractiveDNA
SebasF: So, GameMaker (GML) is a language written in C++ and behave like JavaScript run time. That explain the problems with Memory and CPU overload. I see the limitations and why it is hard or not possible to add new features. The good news is that they can upgrade the GML to a more powerful language in the future because it was written in C++. Thanks for the answer!
SebasF
InteractiveDNA: I don't know what problems are you referring to. We haven't received any complains from users since many versions back. Right now, SAMMI uses ~40MB of memory and <1% of my CPU so that's hardly a bottleneck.
If you have any question you should ask it in our discord server. This is not the place.