-1

I have regex /^\S.*$/ that matches almost any charset including Chinese, Arabic, Cyrillic, etc. characters (which is important for my use case). The problem with this regex is it also matches special characters. I don't need other special characters except ,, ., ', and -. How should I modify my regex?

0

1 Answer 1

1

You might be looking for \p{L} which "matches any kind of letter from any language" according to Regex101.com

Sign up to request clarification or add additional context in comments.

4 Comments

Pardon my ignorance but why does /\p{L}/.test("مجيد الألم "); return false in Node?
No need to apologize! Looks like \p expressions probably just aren't supported in the default JS environment. This library supports it: regular-expressions.info/xregexp.html MY apologies, I assumed it would work after testing it in regex101
Looks like someone extracted the \p specific functionality here: npmjs.com/package/js-regex-pl And according to this answer, JS will support it starting in ECMAScript 2018

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.