Welcome to the LimeSurvey Community Forum

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

Validation regex including unicode characters

  • aquigar
  • aquigar's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #199174 by tpartner
Replied by tpartner on topic Validation regex including unicode characters
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: 4 years 6 months ago by tpartner.
The following user(s) said Thank You: cdorin
The topic has been locked.
  • aquigar
  • aquigar's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #199236 by aquigar
Replied by aquigar on topic Validation regex including unicode characters
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.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 years 6 months ago #199254 by DenisChenu
Replied by DenisChenu on topic Validation regex including unicode characters
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