December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 51 | Matching Non-ASCII Numerals with the Unicode Property Escape |
Let’s say you want to match a number in a language that has a different numeral system, such as Persian or Vietnamese. Remember Recipe 29, Repeating Part of a Regex with Quantifiers, where you validated a PIN code with regex?
This time you want to allow users to use numerals in their own language to create a PIN. But, the problem is that the character class for matching digits (\d) matches only ASCII digits:
| | const re = /^\d{4,6}$/; |

Even setting the Unicode flag won’t help:
Read now
Unlock full access