Create account / Log in

Regular expression not working

Issues with the Vassal engine.

Moderators: uckelman, Tim M

Regular expression not working

Postby greenknight » September 3rd, 2016, 8:56 am

According to the design guide, this should be a valid expression:

{GetProperty("Token 1_Level")=~1|3|5|7|9}

But I only get this:

- Bad Data in Module: Expression evaluation error Expression={GetProperty("Token 1_Level")=~1|3|5|7|9}, Error= inline evaluation of: ``_xyzzy=_plugh();'' internal Error: Unimplemented binary integer operator

Weird, huh?

I just want to check if Token 1_Level is equal to any one of 1,3,5,7, and 9.
greenknight
 
Posts: 49
Joined: November 18th, 2015, 9:46 pm

Re: Regular expression not working

Postby greenknight » September 3rd, 2016, 9:02 am

This seems to work:

GetProperty("Token 1_Level")==1||GetProperty("Token 1_Level")==3||GetProperty("Token 1_Level")==5||GetProperty("Token 1_Level")==7||GetProperty("Token 1_Level")==9||

But quite cumbersome, no?
greenknight
 
Posts: 49
Joined: November 18th, 2015, 9:46 pm

Re: Regular expression not working

Postby Brent Easton » September 4th, 2016, 10:46 pm

Regular Expressions work on Strings, so the correct syntax is

{GetProperty("Token 1_Level")=~"1|3|5|7|9"}

In your version, the expression evaluator is trying to evaluate 1|3 and
not making any sense of it.

Rgds.

On 3/09/2016 6:56 PM, greenknight wrote:
> According to the design guide, this should be a valid expression:
>
> {GetProperty("Token 1_Level")=~1|3|5|7|9}
>
> But I only get this:
>
> - Bad Data in Module: Expression evaluation error
> Expression={GetProperty("Token 1_Level")=~1|3|5|7|9}, Error= inline
> evaluation of: ``_xyzzy=_plugh();'' internal Error: Unimplemented binary
> integer operator
>
> Weird, huh?
>
> I just want to check if Token 1_Level is equal to any one of 1,3,5,7,
> and 9.
>
> _______________________________________________
> Read this topic online here:
> viewtopic.php?p=52065#p52065
> _______________________________________________
> messages mailing list
> messages@vassalengine.org
> http://www.vassalengine.org/mailman/listinfo/messages
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2016.0.7752 / Virus Database: 4649/12935 - Release Date:
> 09/03/16
>
>


--
____________________________________________________________
Brent Easton
Analyst/Programmer
Western Sydney University
Email: b.easton@exemail.com.au
User avatar
Brent Easton
 
Posts: 3160
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Regular expression not working

Postby greenknight » September 5th, 2016, 6:04 am

So simple...

Thanks!
greenknight
 
Posts: 49
Joined: November 18th, 2015, 9:46 pm

Re: Regular expression not working

Postby greenknight » September 5th, 2016, 8:55 am

Oddly enough I get the exact same error message when trying this solution.
greenknight
 
Posts: 49
Joined: November 18th, 2015, 9:46 pm

Re: Regular expression not working

Postby Brent Easton » September 5th, 2016, 12:36 pm

Hmmm, on close examination of the source code, it appears that the =~ has not actually been implemented. This comes as a bit of a surprise to me as I wrote that part of Vassal. Mea culpa. Amazing that no one else has picked it up before. I will submit a fix for this shortly, but in the meantime you will need to use your extended syntax.

Not that you do not need to use the GetProperty function if you are not dynamically generating the property name. Just use the property name, no quotes, so the following would work:

Token 1_Level==1||Token 1_Level==3||Token 1_Level==5||Token 1_Level==7||Token 1_Level==9
User avatar
Brent Easton
 
Posts: 3160
Joined: December 21st, 2007, 3:06 am
Location: Berry, NSW, Australia

Re: Regular expression not working

Postby Dulgin » September 12th, 2016, 6:35 am

Brent Easton wrote:Hmmm, on close examination of the source code, it appears that the =~ has not actually been implemented. This comes as a bit of a surprise to me as I wrote that part of Vassal. Mea culpa. Amazing that no one else has picked it up before. I will submit a fix for this shortly, but in the meantime you will need to use your extended syntax.

Not that you do not need to use the GetProperty function if you are not dynamically generating the property name. Just use the property name, no quotes, so the following would work:

Token 1_Level==1||Token 1_Level==3||Token 1_Level==5||Token 1_Level==7||Token 1_Level==9

Hi Brent,
I know this bug but in the past I could realized all my modules with the old syntax.
But, a fix is very good. :D
Dulgin
 
Posts: 32
Joined: February 6th, 2012, 8:47 pm
Location: Bielefeld/Germany


Return to Technical Support & Bugs

Who is online

Users browsing this forum: jrwatts and 9 guests