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

  • SEARCH
  • Home
  • 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 3460166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:11:48+00:00 2026-05-18T10:11:48+00:00

I have tried: preg_match(/^[a-zA-Z0-9], $value) but im doing something wrong i guess.

  • 0

I have tried:

preg_match("/^[a-zA-Z0-9]", $value)

but im doing something wrong i guess.

  • 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-05-18T10:11:49+00:00Added an answer on May 18, 2026 at 10:11 am

    1. Use PHP’s inbuilt ctype_alnum

    You dont need to use a regex for this, PHP has an inbuilt function ctype_alnum which will do this for you, and execute faster:

    <?php
    $strings = array('AbCd1zyZ9', 'foo!#$bar');
    foreach ($strings as $testcase) {
        if (ctype_alnum($testcase)) {
            echo "The string $testcase consists of all letters or digits.\n";
        } else {
            echo "The string $testcase does not consist of all letters or digits.\n";
        }
    }
    ?>
    

    2. Alternatively, use a regex

    If you desperately want to use a regex, you have a few options.

    Firstly:

    preg_match('/^[\w]+$/', $string);
    

    \w includes more than alphanumeric (it includes underscore), but includes all
    of \d.

    Alternatively:

    /^[a-zA-Z\d]+$/
    

    Or even just:

    /^[^\W_]+$/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried searching over the internet about this problem but not able to
I have tried many permutations but they all don't seems to work well. Am
I am trying to use preg_match to extract numbers only. I have tried the
There are many similar questions, but I've tried about 15 different preg_match examples and
I have tried this but its failing: $whereIsMyCake = ''; // // put all
Have tried to find solutions for this and can't really come up with anything.
I have tried to go through the jungle (really, PayPal, why don't you weed
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried a variety of different solutions found on stack and other places
I have tried everything in the book and EVERYTHING I could find on how

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.