?
Solved

Regular Expression Qestion - Reg Ex Question

Posted on 2014-01-04
3
Medium Priority
?
432 Views
Last Modified: 2014-01-04
Howdy!

Thanks for taking a look at this.  Can anyone tell me why this regular expression is removing spaces?  I think I've been staring at it for too long or something.

$myvar = preg_replace("/[^a-z\d.,-]/i", "", $myvar);

Thanks in advance!

ike1492
0
Comment
Question by:ike1492
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39756478
yes, because the regular expression does removes all that is NOT alpha, decimal, dot, comma, dash.
if you don't want spaces to be removed, you have to add the space into the first part of the expression
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39756479
in code:

$myvar = preg_replace("/[^a-z\d\s.,-]/i", "", $myvar);
0
 

Author Closing Comment

by:ike1492
ID: 39756505
Glad it wasn't a snake! thanks very much!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this article, we’ll look at how to deploy ProxySQL.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question