- Posts: 5
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Validation regex including unicode characters
- aquigar
- Topic Author
- Offline
- New Member
Less
More
3 years 11 months ago #199136
by aquigar
Validation regex including unicode characters was created by aquigar
Hi!:
I´m testing this simple regex to validate the content of a user response:
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:
0x00E1 is the hex code value for "á"
Can anybody help with this?
Thanks in advance
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
3 years 11 months ago - 3 years 11 months ago #199174
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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:
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: 3 years 11 months ago by tpartner.
The following user(s) said Thank You: cdorin
The topic has been locked.
- aquigar
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 2
3 years 11 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.
I'll fill a bug report.
The following user(s) said Thank You: cdorin
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
3 years 11 months ago #199254
by DenisChenu
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.
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
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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.