On Fri, July 13, 2007 3:52 pm, Rick Pasotto wrote:
> I have quotes like the following:
>
> $txt = 'A promise is a debt. -- Irish Proverb';
>
> I'd like to replace all the spaces afer the '--' with  
>
> This is what I've tried:
>
>       $pat = '/( --.*)(\s|\n)/U';

You might want to use \\s and \\n, so you are 100% clear that the PHP
strings have a single \ in them, and that they don't have a newline.

The .* is probably messing you up...

You could probably manage this with some kind of
preg_replace_callback, but it seems to me it would be easier to do:

$txt = 'A promise is a debt. -- Irish Proverb';
$pos = strpos($txt, '--');
$html = substr($txt, 0, $pos) . '--' . str_replace(' ', ' ',
substr($txt, $pos + 2));

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to