1

I need a regexp that allows all languages letters and a specific list of characters to be typed in an input like so:

This field must only contain alphabetic characters, numbers, spaces and _-()[]{},~.;:'"/?#=$%<>@!

I'm using the XRegexp - https://github.com/slevithan/xregexp library for this

Here is my regexp so far

export const INPUT_VALIDATOR_REGEXP = new XRegExp(
  "^[0-9\\p{L} _.&@<>!_\\](){}\\[,\\/\\-.;#=$%:~'\"?+]+$"
);

The problem with it is that it doesn't match the bellow list of languages:

ການທົດສອບ - Laotian
পরীক্ষা - Bengaleza
စမ်းသပ် - Birman
מִבְחָן - Hebraica
પરીક્ષણ- Gujarati
परीक्षण - Hindi
פּרובירן - Idis
ಪರೀಕ್ಷೆ - Kannada
សាកល្បង - Khmer
പരീക്ഷ - Malayalam
चाचणी - Marathi
परीक्षण - Nepalez
ପରୀକ୍ଷା- Odia
ਟੈਸਟ - Punjabi
පරීක්ෂණය - Singhalez
சோதனை - Tamila
పరీక్ష - Telugu

Here I have a fiddle showing the current behaviour - https://jsfiddle.net/cro86wt0/

Solution:

I ended up writing this regex based on @Tom's answer:

"^[0-9\p{L} \u0a00-\u0a7e\u0b00-\u0b7e\က-႞\u0590-\u05fe\u0980-\u09fe\u0e80-\u0efe\u0a80-\u0afe\u0900-\u097F\u0c80-\u0cfeក-\u17fe\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D3E-\u0D43\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D60\u0D61\u0D66-\u0D6F\u0d80-\u0dfe\u0b80-\u0bfe\u0c00-౾_.&@<>!_\](){}\[,\/\-.;#=$%:~'"?+]+$
Andrei Maieras
  • 696
  • 5
  • 15
  • 34
  • Take a look at [this answer](https://stackoverflow.com/a/25067431/16688813) – Tom Nov 09 '21 at 13:12
  • I used the marked solution, it doesn't accept my posted languages – Andrei Maieras Nov 09 '21 at 14:15
  • There is a link in the answer where you can find the range corresponding to languages – Tom Nov 09 '21 at 14:23
  • Yeah, I hoped I didn't have to write a big regex to cover all these languages, but I manage to build it in the end, I updated the question, @Tom if you lilke, write an answer and I'll accept it and remove it from the question, thanks – Andrei Maieras Nov 09 '21 at 14:50

0 Answers0