Regular expression

software development


I need to replace each instance of a dash or multiple adjacent dashes with a single space

for example:

1: -sometext–sometext----------sometext

2: --sometext—sometext----sometext

would ouput:

  1. sometext sometext sometext

  2. sometext sometext sometext

I need to be able to replace dashes regardless of how many instances there are or how many adjacent dashes are in any given instance
PCRE instead of POSIX please, because the manual says of POSIX: “As of PHP 5.3.0 this extension is deprecated, calling any function provided by this extension will issue an E_DEPRECATED notice.”


Or, in PHP terms,
[php]preg_replace("/-+/", " ", $str);[/php]

Or, in PHP terms,
[php]preg_replace("/-+/", " ", $str);[/php]


that did the trick, thanks a bunch