Re: Propably easy regex question
| From: | Sheridan Saint-Michel | Date: | Wed, 25 Jul 2001 14:01:05 +0000 |
| Subject: | Re: Propably easy regex question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59544@lists.php.net to get a copy of this message | ||
I would just do something like
if(substring($text, 0, 1) == ">")
{
$text = ">" . $text;
}
else
{
$text = "> " . $text;
}
Where $text is a line of text from your message.
Hope that helps
Sheridan
----- Original Message -----
From: Nicklas af Ekenstam <n@nille.org>
To: <php-general@lists.php.net>
Sent: Tuesday, July 24, 2001 4:23 PM
Subject: [PHP] Propably easy regex question
> Hi
>
> Could anyone help me with a code snippet that would take a string and add
'>
> ' to it at the start of every new line just as a mail client does when
> replying to a mail?
> I.e. I would like this:
>
> Hello,
>
> How are you?
>
> To look like this:
>
> > Hello,
> >
> > How are you?
>
> When it's done.
>
> (Actually I would love it if it would also look for existing > at the
> beginning of a line, and if there are any, just add the > and not the
white
> space but perhaps thats too much to ask for ;-)
>
> Thanks!
>
> - Nille
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net