Reputation: 11554
Here is my regex for testing address:
^((([\u0600-\u06FF])+\s?([0-9()،,-]?)+\s?))+$
but when address contains /
or \
character, RegexMatchTimeoutException
occurs.
here is sample input:
"تهران - خیابان سهروردی - خیابان 19 شرقی، کوچه 59, پلاک 39525، / طبقه ٣"
Upvotes: 1
Views: 556
Reputation: 627126
The problem with your regex is that it contains nested quantifiers that quantify optional patterns.
Use linear logic:
^[\u0600-\u06FF]+(?:[\s0-9()،,-]+[\u0600-\u06FF]+)*$
See the regex demo
Details:
^
- start of string[\u0600-\u06FF]+
- 1 or more symbols from the given Unicode range(?:[\s0-9()،,-]+[\u0600-\u06FF]+)*
- 0+ sequences of:
[\s0-9()،,-]+
- 1+ symbols: either whitespace, digits, (
, )
, ،
, ,
or -
[\u0600-\u06FF]+
- 1 or more symbols from the given Unicode range$
- end of string.Upvotes: 4