Welcome to the LimeSurvey Community Forum

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

Validation regex including unicode characters

More
5 years 3 months ago #199136 by aquigar
Hi!:

I´m testing this simple regex to validate the content of a user response:
Code:
/^[A-Z0-9\s]+$/

It matches capital letters, numbers and whitespaces. It seems to be correct and works fine.

But assume I would like to include the unicode char "á".

I've tested the following regexes with no results:

Code:
/^[áA-Z0-9\s]+$/
 
/^[\x00E1A-Z0-9\s]+$/
 
/^[\x{00E1}A-Z0-9\s]+$/
 
/^[\u00E1A-Z0-9\s]+$/

0x00E1 is the hex code value for "á"

Can anybody help with this?

Thanks in advance
Code:
 
The topic has been locked.
More
5 years 3 months ago - 5 years 3 months ago #199174 by tpartner
That appears to be a bug with the regexMatch() function. Please file a bug report.

This script placed in the question source shows a valid regular expression:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
    $('#question{QID} input:text').on('keyup', function(){
      console.log($(this).val().match(/^[a-zA-ZáÁ0-9\s]+$/));
    });
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 3 months ago by tpartner.
The following user(s) said Thank You: cdorin
The topic has been locked.
More
5 years 3 months ago #199236 by aquigar
Thank you for your quick reply and your time.
I'll fill a bug report.
The following user(s) said Thank You: cdorin
The topic has been locked.
More
5 years 3 months ago #199254 by DenisChenu
The important things are we must have same result in PHP and JS

Here the JS function used : github.com/LimeSurvey/LimeSurvey/blob/70...ascript.js#L847-L858

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose