Avatar of IT Genesis
IT Genesis
 asked on

Regular express validation

I need validation expression only Arabic character and Three names
ASP.NET

Avatar of undefined
Last Comment
IT Genesis

8/22/2022 - Mon
Terry Woods

What do you mean by three names?

Do you mean you want to match?
Charles William Harry

Open in new window

but not
Bernie Donald

Open in new window

IT Genesis

ASKER
yes two spaces i try to use thtis \w+ \w+ but not work
Terry Woods

When using a pattern for validation purposes, you usually need to add start and end of string placeholders (^ and $) to ensure no additional characters exist before or after the characters matched by the pattern.

eg the pattern ab?d would match the value abcde but pattern ^ab?d$ would not match it.

So for 3 words separated by a space character you might want to try pattern:
^\w+ \w+ \w+$

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
IT Genesis

ASKER
yes but it run with English  character only no different  language
Terry Woods

Then you could use this:
^[a-zA-Z]+ [a-zA-Z]+ [a-zA-Z]+$

Open in new window

Or the same thing, but shorter:
^([a-zA-Z]+ ){2}[a-zA-Z]+$

Open in new window

IT Genesis

ASKER
it also work with English letter
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Terry Woods

Sorry, you'll need to better explain what the problem is.
ASKER CERTIFIED SOLUTION
IT Genesis

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
IT Genesis

ASKER
@Terry Woods

Thanks for your help