Regex question


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!

      
dwaxAsked:
Who is Participating?
 
RoonaanConnect With a Mentor Commented:
I forgot to include the semicolon:

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

-r-
0
 
RoonaanCommented:
preg_match('/(&nbsp|\s)/', $test, $matches);

-r-
0
 
dwaxAuthor Commented:

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

From novice to tech pro — start learning today.