#50232 [Com]: preg_replace - pattern description omits mention of string delimiter
| From: | simonokewode at hotmail dot com | Date: | Tue, 24 Nov 2009 20:38:47 +0000 |
| Subject: | #50232 [Com]: preg_replace - pattern description omits mention of string delimiter | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3333@lists.php.net to get a copy of this message | ||
ID: 50232
Comment by: simonokewode at hotmail dot com
Reported By: simonokewode at hotmail dot com
Status: Open
Bug Type: Documentation problem
Operating System: n/a
PHP Version: Irrelevant
New Comment:
Well that's good to know. So someone needing to move from ereg_replace
to this function is expected to know that they should read the "Regular
Expressions (Perl-Compatible)" description first?
A note to that effect would help the many people who will be coming
straight here for a single purpose. If PHP is eliminating a function, I
think it is right to make it straightforward to convert.
Previous Comments:
------------------------------------------------------------------------
[2009-11-24 19:48:01] daniel dot egeberg at gmail dot com
It already says that delimiters are needed around the pattern here:
http://php.net/manual/en/intro.pcre.php
------------------------------------------------------------------------
[2009-11-19 15:56:22] simonokewode at hotmail dot com
Description:
------------
Users moving from ereg_replace to preg_replace will not know that
delimiters are required unless already familiar w/ regex. Huge numbers
of newbies will need to do this.
This entry does not need to explain how to use them, but should mention
that they are required, and there should be an explanation of regex
delimiters somewhere in the manual since they are critical for basic
functionality.
The preg_quote entry mentions delimiters, and may be a good reference
link from the preg_replace pattern description.
A very simple example of preg_replace in the function list would
highlight the existence and use of delimiters; then the complex examples
will be easier to understand.
preg_replace('/text/', 'new text', $string)
Reproduce code:
---------------
---
From manual page: function.preg-replace
---
Parameters
pattern
The pattern to search for. It can be either a string or an array
with strings.
The e modifier makes preg_replace() treat the replacement parameter
as PHP code after the appropriate references substitution is done. Tip:
make sure that replacement constitutes a valid PHP code string,
otherwise PHP will complain about a parse error at the line containing
preg_replace().
Expected result:
----------------
Parameters
pattern
The pattern to search for. It can be either a string or an array
with strings. Use regex delimiters on strings [link to preg_quote() or
regex ref].
The e modifier makes preg_replace() treat the replacement parameter
as PHP code after the appropriate references substitution is done. Tip:
make sure that replacement constitutes a valid PHP code string,
otherwise PHP will complain about a parse error at the line containing
preg_replace().
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50232&edit=1