|
Posted by zainally on 03/19/07 05:57
On Mar 19, 5:08 am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> zainally wrote:
> > I want to detect uppercase characters in a string and separate the two
> > words in it by a space. I know I can use preg_replace for it, but I am
> > not very good at regular expressions. Can someone help?
>
> You want something like this:
>
> $s = preg_replace('/([^\s])([A-Z])/', '\1 \2', $s);
>
> You probably want to consider what sort of behaviour is "desirable" in
> edge cases like this:
>
> Print404ErrorPage
> GetHTTPRequest
> Jpeg2Gif
>
> The above regular expression will output:
>
> Print404 Error Page
> Get H T T P Request
> Jpeg2 Gif
>
> which might not be what you wanted!
>
> --
> Toby A Inkster BSc (Hons) ARCS
> Contact Me ~http://tobyinkster.co.uk/contact
> Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
>
> * = I'm getting there!
That is exactly what I want. Thanks Toby!
Navigation:
[Reply to this message]
|