Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Regex question

Posted on 2006-06-19
3
Medium Priority
?
220 Views
Last Modified: 2008-03-04

Hi,

Struggling with the following, there's an adress, i would like to preg_match either an   or an empty space ([\s] ?) as both can be present.

Streetname City
Streetname City

So doing something like this:
preg_match('/ /s',$test,$matches);      
$show = $matches[0];      
echo "$show";

Works for the first sentence, but:
How can i catch both possibilties in one?

Any help would be great!

      
0
Comment
Question by:dwax
[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 49

Expert Comment

by:Roonaan
ID: 16934661
preg_match('/(&nbsp|\s)/', $test, $matches);

-r-
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 200 total points
ID: 16934664
I forgot to include the semicolon:

preg_match('/( |\s)/', $test, $matches);

-r-
0
 

Author Comment

by:dwax
ID: 16934727

Thanks!
You just saved my keyboard from flying out the window...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

722 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