1

I am trying to find a regular expression where the input is just arabic, space and numbers (but with no predefined order)

Regex regex = new Regex("[\u0600-\06ff\\s0-9]*");

when the input is 4, this is the exception:

parsing "[؀-

{"parsing \"[؀-\06ff\\s0-9]*\" - [x-y] range in reverse order."}

8
  • the second item of the range lacks 'u' in the '\u' Commented Jul 30, 2014 at 12:50
  • @PW. so u mean to change it to \\u? Commented Jul 30, 2014 at 12:51
  • In other words, \u0600 is an underscore \06ff is not a valid unicode point. Commented Jul 30, 2014 at 12:54
  • 1
    no I mean turn \u0600-\06ff into \u0600-\u06ff Commented Jul 30, 2014 at 12:54
  • 2
    Please put more of your code, so that at least someone can try reproducing it completely if run as is without changing anything. Commented Jul 30, 2014 at 13:20

1 Answer 1

3

What about following code line to validate that the entire string contains only Arabic letters, whitespaces and digits using verbatim-string-literal?

Regex regex = new Regex(@"^[\u0600-\u06ff\s\d]+$");

Or with regluar string literal:

Regex regex = new Regex("^[\\u0600-\\u06ff\\s\\d]+$");

By removing ^ (begin of string) and $ (end of string) the expression would search for 1 or more strings consisting only of arabic letters, whitespaces and digits instead of validating if the entire string consists of only arabic letters, whitespaces and digits (and is not empty).

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.