Need regex for nota

Need regex for nota

SpringRTS Perl Autohost for Dedicated Server

Moderators: Moderators, Lobby Developers, SPADS AutoHost

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Need regex for nota

Post by Forboding Angel »

modName:~NOTA\ d+\.\d+

Doesn't work. Nota's modname is currently "NOTA 1.88e"

I was trying to use the regex for evo as an example, but apparently that is fail. Halp?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Need regex for nota

Post by Anarchid »

What regex dialect?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Need regex for nota

Post by Silentwings »

I'm lost, is this an issue with SPADS or are you just confused by regex?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

It's for an autohost. The regex always finds the latest version installed and sets that as the game version.

For example, evo uses this:
modName:~Evolution\ RTS\ \-\ v\d+\.\d+

@anarchid, no idea.

http://planetspads.free.fr/spads/doc/sp ... et:modName
modName (hosting setting)
Explicit name Mod name
Description Name of the hosted mod (as returned by the GetPrimaryModName UnitSync function).
The corresponding mod must be available locally in the "games" or "packages" subdirectories of springDataDir.
It is also possible to use a regular expression instead of the exact mod name, by prefixing the value with "~". SPADS will then choose the latest mod in lexicographic order whose name match the regular expression, so it should automatically select the latest version of a given mod.
Format / Allowed values <modName> (<modName> must be the exact mod name, as returned by the GetPrimaryModName UnitSync function)
~<regularExpression> (at least one mod name must match the <regularExpression> regular expression)
Default value %modName% (set during installation, example: "~Balanced Annihilation V\d+\.\d+")
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Need regex for nota

Post by Silentwings »

Yes - are you saying that SPADS handles regex incorrectly, or are you just asking for help with regex?

If the latter, https://regex101.com/ is handy.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Need regex for nota

Post by Nemo »

They're just Perl regex without anything fancy going on. SPADS does some minor magic to generate them based on the mod name given to it while setting up.

Code: Select all

NOTA\ d+\.\d+
is broken for two reasons.
  • The first 'd' character class is separated from its backslash: should be \d+, not \ d+
  • The second "\d+" does not match letters, like 'e'.
Thus, the regex does not match

Code: Select all

NOTA 1.88e
because of the 'e' on the end. \d stands for 'digit', so

Code: Select all

NOTA \d+\.\d+
matches

Code: Select all

NOTA <one or more digits>.<one or more digits>
If you'd like it to deal with the 'e' on the end, you can do something like this:

Code: Select all

NOTA \d+\.\w+
which will match

Code: Select all

NOTA <one or more digits>.<one or more word characters, which can be digits or letters>
This should be fine given the blurb higher up in the thread that SPADS uses lexical (alphabetic) ordering.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Need regex for nota

Post by Jools »

Nemo wrote:They're just Perl regex without anything fancy going on. SPADS does some minor magic to generate them based on the mod name given to it while setting up.
  • The first 'd' character class is separated from its backslash: should be \d+, not \ d+
.
I thought that the "\ " is there to escape and match the space.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Re: Need regex for nota

Post by Nemo »

Jools: Not quite. Perl matches whitespace as literals by default:

Code: Select all

$ perl -E 'my $str = " foobar"; say $str =~ /^ \w+$/;'
1
The escape to match is only needed if you have the /x flag enabled on the regex (so you can embed spaces and comments in the pattern for better readability), but that's not the case in SPADS: https://github.com/Yaribz/SPADS/blob/ma ... ds.pl#L917.

In any case, 'd+' without the slash to introduce the character class is likely not what was intended, given the context of matching version numbers. "d+" means "one or more appearances of the letter 'd'" :)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Need regex for nota

Post by Jools »

I have the same problem, for zero-k:

I'm using this regex:

Code: Select all

modName:~Zero-K\ v.+
It matches only, or maybe with first priority Zero-K v.1.3.9.0, whereas there is also Zero-K v.1.3.13.0

If I instead try with this regex (tested to match on http://www.regextester.com/)

Code: Select all

modName:~Zero-K v.\d+.\d+.\d+.\d+
Now it says
Unable to find mod matching "Zero-K v.\d+.\d+.\d+.\d+" regular expression
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

Nemo, you are awesome. Thank you for making it so clear :-) seems simple as hell now lol
Last edited by Forboding Angel on 27 Nov 2015, 23:43, edited 1 time in total.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Need regex for nota

Post by Jools »

Was nemo though.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

Oh derp, my mistake :oops:
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Need regex for nota

Post by bibim »

Jools wrote:It matches only, or maybe with first priority Zero-K v.1.3.9.0, whereas there is also Zero-K v.1.3.13.0
Where did you get these Zero-K packages from? As far as I know there is no dot between "v" and the version number in official Zero-K packages
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

Perhaps it would make more sense to just point out that he has an extra unnecessary dot in-between the v and the number than try to paint him as a fool who doesn't understand what he is doing.

Allow me to word it in a less aggressive tone...

@jools, in your examples, you are putting a dot inbetween the v and the number. Are you sure that that dot should be there? The reason I ask is that according to the packages here: http://zk.repo.springrts.com/builds/?C=M;O=D there isn't any dot there. Maybe that is the issue?

User was warned for this post; felony 1.

Please contain this petty dispute to a single thread. Better yet admit fault and just pack it in.

-- FLOZi
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Need regex for nota

Post by bibim »

Forboding Angel wrote:Perhaps it would make more sense to just point out that he has an extra unnecessary dot in-between the v and the number than try to paint him as a fool who doesn't understand what he is doing.
It seems your "extremely high reading comprehension level" is deficient, I never painted him as a fool. He said that his regex matches a package "Zero-K v.1.3.9.0" and that he also has a package "Zero-K v.1.3.13.0", I just trusted him that's all. I don't even know how Zero-K packages are generated and since official Zero-K hosts aren't connected to main Spring lobby anymore I can't even compare the names, hence my "As far as I know"... (the names shown here are just file names, not mod names as seen by unitsync and used by SPADS, so the version number formats aren't necessarily the same).
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Need regex for nota

Post by Jools »

Hmmm, it seems indeed that the dot would be the issue here. I didn't know the location of zk-repo so I could not open one archive and look at the real names. Now I managed to do that and I see that the official name is

Code: Select all

Zero-K v1.3.11.3
However, I have that dot there before the v but it's supposed to match any character except line breaks, but it seems it needs to match the dot literally. I think it works if I remove that dot from the regex.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

bibim wrote:...I never painted him as a fool.
bibim wrote:Where did you get these Zero-K packages from? As far as I know there is no dot between "v" and the version number in official Zero-K packages
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Need regex for nota

Post by bibim »

You can quote me as much as you want, even removing the parts where I explain why you are wrong, but it won't change the fact that you are wrong :wink:
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Need regex for nota

Post by Jools »

It still hosts Zero-K v1.3.9.0 instead of Zero-K v1.3.11.3, presumably because 9 comes before 1 numerally if you only consinder 1 digit after the period. I use this expression:

Code: Select all

modName:~Zero-K v\d+.\d+.\d+.\d+
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Need regex for nota

Post by Forboding Angel »

Flozi wrote:
User was warned for this post; felony 1.

Please contain this petty dispute to a single thread. Better yet admit fault and just pack it in.

-- FLOZi
What the hell are you talking about anyway? One thing has nothing to do with the other... ffs.
Post Reply

Return to “SPADS AutoHost”