Welcome, Guest
Username: Password: Remember me

TOPIC: regex validation problem

regex validation problem 3 years 4 months ago #60022

  • lovepade
  • lovepade's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 93
  • Karma: 0
Hi guys

This
^[1-9].[0-9]|[1][0-1].[0-9]|[1][2].[0]
should allow everything from allow numbers from 1.0 to 12.0

as per pythex.appspot.com/ it works.

But limesurvey (latest stable) keeps telling me that e.g. 5.8 is not correct?

I have sat max chars to 4

Any idesd
The administrator has disabled public write access.

Re: regex validation problem 3 years 4 months ago #60023

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2643
  • Thank you received: 313
  • Karma: 115
Is it just 5.8? What happens if you try it with other figures?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: regex validation problem 3 years 4 months ago #60048

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4141
  • Thank you received: 768
  • Karma: 349
Try:
/^[1-9]\.[0-9]$|^[1][0-1]\.[0-9]$|^[1][2]\.[0]$/
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.

Re: regex validation problem 3 years 4 months ago #60067

  • lovepade
  • lovepade's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 93
  • Karma: 0
Hi tpartner - thanks a lot that works.

Lesson: Always remember to escape - and don't trust pythex completely :-D
The administrator has disabled public write access.

Re: regex validation problem 3 years 4 months ago #60073

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4141
  • Thank you received: 768
  • Karma: 349
Always remember to escape
Yup, and also to define the beginning and end of the string with the ^ and $ characters.
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.
Moderators: ITEd
Time to create page: 0.161 seconds
Donation Image