Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:22:30+00:00 2026-06-03T11:22:30+00:00

I need a Regex for PHP to do the following: I want to allow

  • 0

I need a Regex for PHP to do the following:

I want to allow [a-zα-ωá-źа-яա-ֆა-ჰא-ת] and chinese, japanese (more utf-8) letters;
I want to ban [^٩٨٧٦٥٤٣٢١٠۰۱۲۳۴۵۶۷۸۹] (arabic numbers);

This is what i’ve done:

function isValidFirstName($first_name) {
    return preg_match("/^(?=[a-zα-ωá-źа-яա-ֆა-ჰא-ת]+([a-zα-ωá-źа-яա-ֆა-ჰא-ת' -]+)?\z)[a-zα-ωá-źа-яա-ֆა-ჰא-ת' -]+$/i", $first_name);
}

It looks like it works, but if I type letters of more than 1 language, it doesn’t validate.

Examples: Авпа Вапапва á-ź John – doesn’t validate.
John Gger – validates, á-ź á-ź – validates.

I would like to this all of these.

Or if there’s a way, to echo a message if user entered more lingual string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:22:32+00:00Added an answer on June 3, 2026 at 11:22 am

    I can’t reproduce the failure cases here (Авпа Вапапва á-ź John validates just fine), but you can simplify the regex a lot – you don’t need that lookahead assertion:

    preg_match('/^[a-zα-ωá-źа-яա-ֆა-ჰא-ת][a-zα-ωá-źа-яա-ֆა-ჰא-ת\' -]*$/i', $first_name)
    

    As far as I can tell from the character ranges you’ve given, you don’t need to exclude the digits because anything outside these character classes will already cause the regex to fail.

    Another consideration: If your goal is to allow any letter from any language/script (plus some punctuation and space) you can (if you’re using Unicode strings) further simplify this to:

    preg_match('/^\pL[\pL\' -]*$/iu', $first_name)
    

    But generally, I wouldn’t try to validate a name by regular expressions (or any other means): Falsehoods programmers believe about names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a regex that also matches Chinese, Greek, Russian, ... letters. What I
I need a regex that matches the following (the brackets indicate I want to
i need an regex to do the following: redirect EVERY request to the index.php
I have the following string: $/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php I need to create regex pattern and take
I need to create a regex in PHP that will identify the following tokens
For example: http://foobar.com/foo/bar/foobar.php From this address, I need to extract the following: http://foobar.com/foo/bar I
I need a PHP Regex that can parse .strings files. In particular, it needs
I need a regex or a function in PHP that will validate a string
I need the regex to find function calls in strings in php, I have
I need a regex for four-digit numbers separated by comma (default can also be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.