Page 1 of 1

Need regex for nota

Posted: 27 Nov 2015, 09:29
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?

Re: Need regex for nota

Posted: 27 Nov 2015, 11:15
by Anarchid
What regex dialect?

Re: Need regex for nota

Posted: 27 Nov 2015, 11:26
by Silentwings
I'm lost, is this an issue with SPADS or are you just confused by regex?

Re: Need regex for nota

Posted: 27 Nov 2015, 11:44
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+")

Re: Need regex for nota

Posted: 27 Nov 2015, 11:52
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.

Re: Need regex for nota

Posted: 27 Nov 2015, 12:13
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.

Re: Need regex for nota

Posted: 27 Nov 2015, 14:53
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.

Re: Need regex for nota

Posted: 27 Nov 2015, 15:39
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'" :)

Re: Need regex for nota

Posted: 27 Nov 2015, 17:07
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

Re: Need regex for nota

Posted: 27 Nov 2015, 21:58
by Forboding Angel
Nemo, you are awesome. Thank you for making it so clear :-) seems simple as hell now lol

Re: Need regex for nota

Posted: 27 Nov 2015, 22:38
by Jools
Was nemo though.

Re: Need regex for nota

Posted: 27 Nov 2015, 23:43
by Forboding Angel
Oh derp, my mistake :oops:

Re: Need regex for nota

Posted: 28 Nov 2015, 10:23
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

Re: Need regex for nota

Posted: 28 Nov 2015, 11:32
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

Re: Need regex for nota

Posted: 28 Nov 2015, 12:57
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).

Re: Need regex for nota

Posted: 28 Nov 2015, 15:38
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.

Re: Need regex for nota

Posted: 28 Nov 2015, 19:27
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

Re: Need regex for nota

Posted: 28 Nov 2015, 21:17
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:

Re: Need regex for nota

Posted: 29 Nov 2015, 01:39
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+

Re: Need regex for nota

Posted: 29 Nov 2015, 04:45
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.