On 4/15/08, Pete Clark <[EMAIL PROTECTED]> wrote:
>
> (For some reason, when I emailed this message, it didn't get through,
>  although a reply which I posted later did, so apologies if this is a
>  duplicate)
>
>  I am trying to create some code to edit user input, in particular, to
>  ensure that there is a space after a period.
>
>  That is, I want to change "Hello world.Hello world" into "Hello world.
>  Hello world"
>
>  I have got as far as
>  preg_replace('/\.\S/i', ". $0", 'Hello world.Hello world');
>  which gives me
>  "Hello world. .Hello world"
>
>  Can anyone figure out the correct code.

Hi.
Try out this one:

preg_replace('/\.([^\s])/i', ". $1", 'Hello world. Hello world');

It searches for a . (comma) with a nonspace character after it and
replaces the whole thing with the . (comma-space) and the non-space
chaacter it have found.

regards
mmlado

Reply via email to