1
votes

I use the following to check if a given string unicodeName is within a certain character range:

unicodeName.matches(".*[^\u1000-\u103f].*")

However, this does not allow for the inclusion of space characters in the name. If I want the user to type space in the name and at the same time want the matcher to return true what would the regex be?

Example:

This works fine for me

works

but this doesn't

enter image description here

2
Any example to help us?Thomas Ayoub
.* allows any amount of spaces. Please clarify what you need.Wiktor Stribiżew
I think you want [ \u1000-\u103f]*. Maybe you could trim the string after, and if need check its length to ensure input wasn't just whitespace or empty.dave
@Thomas I have updated the question to give examples.Sandah Aung

2 Answers

2
votes

I would use:

^[\\s\\u1000-\\u103f]*$

(don't forget to escape \)

1
votes

Following regex work for me

[A-Za-z\\\s]*