Skip to content Skip to sidebar Skip to footer

Korean And Alphabet Regex Returning False

I have been having trouble validating a form input for my website. Im looking the accept both english characters and korean characters for the name field. I had no trouble with inp

Solution 1:

In your case, it is enough to remove the curly braces from the Unicode escape sequences:

/[^a-zA-Z0-9\u3130-\u318F\uAC00-\uD7AF]/g

Note that \u{3130} is only possible in ECMAScript 6 compatible browsers, please refer to ECMAScript 6 Compatibility Table.

The JavaScript String Literals Guide calls \uXXXXUnicode escape sequences:

The Unicode escape sequences require at least four characters following \u. Example: \u00A9 = ©

And \u{XXXXX} are called Unicode code point escapes:

New in ECMAScript 6. With Unicode code point escapes, any character can be escaped using hexadecimal numbers so that it is possible to use Unicode code points up to 0x10FFFF. With simple Unicode escapes it is often necessary to write the surrogate halves separately to achieve the same.

Example:\u{2F804} // The same with simple Unicode escapes: \uD87E\uDC04

Post a Comment for "Korean And Alphabet Regex Returning False"