Welcome, Guest
Username: Password: Remember me

TOPIC: Condition on Odd/Even Numbers?

Condition on Odd/Even Numbers? 3 years 5 months ago #60871

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
Hello community,

I would like to set a condition based on a number entry of an earlier question. Thereby I want to base the condition whether the previous entry was an odd or even number.

Can anyone tell me, how I can implement this with RegEx?

I figured out that

Odd Numbers is "^\d*[13579]$" and Even Numbers is "^\d*[02468]$".

But how can I implement this in Limesurvey?

Thanks a lot for your help!

P.s.: I'm using Limesurvey Version 1.90+ Build 9642.
The administrator has disabled public write access.

Re: Condition on Odd/Even Numbers? 3 years 5 months ago #60884

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
In the conditions interface, you need to set the comparison operator to "Regular expression" - docs.limesurvey.org/Setting+conditions&s..._comparison_operator.

Capture_2.JPG
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: piquadrat

Aw: Re: Condition on Odd/Even Numbers? 3 years 5 months ago #60887

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
Thanks a lot - it turned out that the problem is, that the RegEx Code only works on numbers between 0-9. Do you have any idea how it can be changed to be used with numbers up to 4 digits (e.g. 1995)?
The administrator has disabled public write access.

Re: Condition on Odd/Even Numbers? 3 years 5 months ago #60889

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
Try this to find if the last digit in the string is odd or even:

Even:
[02468]$

Odd:
[13579]$
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: piquadrat

Aw: Re: Condition on Odd/Even Numbers? 3 years 5 months ago #60893

  • piquadrat
  • piquadrat's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Thank you received: 1
  • Karma: 0
Thanks a lot - that helped me out!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.108 seconds
Donation Image