Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Regular Expression to allow french text as well as english text?

  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 6 months ago #189158 by blocka
I have a question entitled "Last Name" -- I want to make the field Mandatory, and use a regular expression to restrict the input to only letters, dashes, and apostrophe (letters must allow for foreign characters as well -- like French accented characters, etc).

I checked here: manual.limesurvey.org/Using_regular_expressions , but there are no examples for this scenario.

Can anyone provide a regex that will prevent a question from being submitted if it doesn't meet the above?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189164 by DenisChenu
Maybe best question is : what is disallowed ?

For example to allow only non white-space you can use /^(\S)*$/ .

But to disallow specific c&aracter : /^([^\s|!|?|\.]|)*$/

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 6 months ago #189169 by blocka
Thanks Denis, generally I would agree, but we have to limit our input to only French or English characters.

We've tried both:
/^[a-zA-ZÀÂÉÊÈËÌÏÎÔÙÛÇÆŒàâéêèëìïîôùûçæœ '-]{3,100}$/
and
/^[^@!#$%^&?*+=_0-9~`:;\"<>[\]{}\/\\]{3,100}$/

Both of which work on regex101.com but don't work in the validation field in LS3

Any help that can be provided is greatly appreciated.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189174 by DenisChenu
Ah, yes … just checked …
Your expression is OK in PHP but not in JS, because js encode htmlentities when get value.

Can you try with
regexMatch("/^[a-zA-ZÀÂÉÊÈËÌÏÎÔÙÛÇÆŒàâéêèëìïîôùûçæœ '-]{3,100}$/",html_entity_decode(self.NAOK))

PS : it can be great to report the issue :
LemVal must encode only when view, but not when used in another function (for example strlen(self.NAOK) with é return 8 …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 4 years 6 months ago by DenisChenu. Reason: PS
The topic has been locked.
  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 6 months ago #189190 by blocka
Thank you for your continued support.

I copied the expression into the validation field and tried again, but it still doesn't appear to work.

This is what I have in my validation field:



I've also attached my question.

File Attachment:

File Name: question_12421.lsq
File Size:2 KB
The topic has been locked.
More
4 years 6 months ago #189191 by jelo

DenisChenu wrote: Can you try with
regexMatch("/^[a-zA-ZÀÂÉÊÈËÌÏÎÔÙÛÇÆŒàâéêèëìïîôùûçæœ '-]{3,100}$/",html_entity_decode(self.NAOK))
:

Is Regexmatch available in ExpressionScript / ExpressionManager?

Not still planned?
manual.limesurvey.org/Expression_Manager..._or_Being_Considered

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189194 by DenisChenu
Not in validation, in Question validation equation

See sample (with strlen to show the issue)

@jelo : no, included since … 1.98 i think ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • blocka
  • blocka's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 6 months ago #189197 by blocka
@DenisChenu Oh wow! Fantastic, that totally works. Thank you so much for helping out!
The topic has been locked.
More
4 years 6 months ago #189203 by jelo

DenisChenu wrote: @jelo : no, included since … 1.98 i think ?

Thanks, the English manual already list the function as implemented. The GERMAN manual page is outdated. Sorry.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189208 by holch

The GERMAN manual page is outdated. Sorry.

Why would you read anything else than the English manual, if you know English?

First of all, the manual is always behind the actual software. Then imagine a manual page that has to be translated from the original manual page...

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose