0

how to capture with regex everything but spaces

For example I have Hello Word

What regex to use to output HelloWord

(I'm using Regex and php) Best regards

amorino
  • 375
  • 1
  • 3
  • 16
  • possible duplicate of [Matching a space in regex](http://stackoverflow.com/questions/559363/matching-a-space-in-regex) – hakre Apr 20 '14 at 15:03

2 Answers2

1
preg_replace('/\s+/', '', $str)
hakre
  • 193,403
  • 52
  • 435
  • 836
Alex
  • 8,055
  • 7
  • 39
  • 61
0
<?php
$string = "Hello Word";
$string = preg_replace('/ /', '', $string);
echo $string;
//HelloWord
?>

http://ideone.com/RvYkdA

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268