#50232 [NEW]: preg_replace - pattern description omits mention of string delimiter

From: Date: Thu, 19 Nov 2009 15:56:22 +0000
Subject: #50232 [NEW]: preg_replace - pattern description omits mention of string delimiter
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3246@lists.php.net to get a copy of this message
From:             simonokewode at hotmail dot com
Operating system: n/a
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  preg_replace - pattern description omits mention of string delimiter

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 bug report at http://bugs.php.net/?id=50232&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=50232&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=50232&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=50232&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=50232&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50232&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=50232&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=50232&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=50232&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=50232&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=50232&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=50232&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=50232&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=50232&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=50232&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50232&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50232&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=50232&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=50232&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=50232&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=50232&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=50232&r=mysqlcfg



Thread (6 messages)

« previous php.doc.bugs (#3246) next »