RE: [PHP] regex and newline
| From: | Michael | Date: | Fri, 02 May 2003 04:12:03 +0000 |
| Subject: | RE: [PHP] regex and newline | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146061@lists.php.net to get a copy of this message | ||
Hi John
Let me make it more clear. I did a sample of what I want done below. If I
type in the box "[list]" and then press the enter key to get the "\n". Then
if I press the submit button I want "[list]\n" to turn to "[changed]". I
don't know how to search for newlines in input boxes. Hopes that's more
clear.
test.php
========
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="test.php" >
<textarea name="text" rows="5" cols="25">
<?php
if ( isset($_POST['text']) )
{
$text = str_replace("[list]\n", "[changed]", $_POST['text']);
echo $text;
}
?>
</textarea><br>
<input type="submit" type="button">
</form>
</body>
</html>
-----Original Message-----
From: John W. Holmes [mailto:holmes072000@charter.net]
Sent: May 1, 2003 11:46 PM
To: 'Michael'; 'Php-General@Lists.Php.Net'
Subject: RE: [PHP] regex and newline
> $text = "[list]\n";
> $text = preg_replace("/\[list\]\n?/i","<ul>", $text);
>
> What I want $text to look like is this afterwards:
> $text="<ul>"
Umm... str_replace("[list]\n",'<ul>',$text); ??
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03