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 1004313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:06:54+00:00 2026-05-16T08:06:54+00:00

Recently i’ve switched to PHP 5.3+ and after that migration i learned that the

  • 0

Recently i’ve switched to PHP 5.3+ and after that migration i learned that the eregi() function has been depreciated, its the function i mostly used for my regex needs.

But now i had to switch to preg_match() function, i am having trouble validating a certain condition.

Hello World

I want the preg_match to validate the above “hello world” string, the string contains whitespace in it.

But i want it to validate even if there is no whitespace “helloWorld” or just “hello”.

What i’m trying to do is that in my script i have a text-field for the category title, i want it to accept spaces in it and no other special characters (such as ._-+*,).

I have made it to work but i’m not sure if thats the right way which i’m using.

preg_match('/^[a-zA-Z0-9\s]*$/', $cat_name);'

Any help would be appreciated.

  • 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-16T08:06:55+00:00Added an answer on May 16, 2026 at 8:06 am

    Looks OK, but will accept empty string, so you can change * to +
    Remember that this regex will propably no accept language-specified UTF-8 chars.

    See that comment in manual:
    http://www.php.net/manual/en/function.preg-match.php#95828

    Also note, that some specific charaters are very often used in titles, like ” and maybe it would better to allow it.

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

Sidebar

Related Questions

Recently the PHP manual started showing the following warning on every mysql function page:
Recently I've been doing quite the project mostly working with the DateTime class. Now,..
Recently I have been told that static class/methods are evil. Take for example my
Recently I noticed (after others have extended the project) that the compile time significantly
Recently our site has been deluged with the resurgence of the Asprox botnet SQL
Recently, I was writing a class in which I discovered that I could reduce
recently, while working on a db2 -> oracle migration project, we came across this
Recently I'm doing some work on RTMP streaming, that is using Flowplayer to integrate
Recently I've noticed that on occasion I do not get a mayorship notification when
Recently I have been dealing with windows LogonUser API. The LogonUser api returns different

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.