|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-24 19:48 UTC] daniel dot egeberg at gmail dot com
[2009-11-24 20:38 UTC] simonokewode at hotmail dot com
[2009-12-03 06:43 UTC] traveltechrcs at yahoo dot com
[2009-12-19 21:10 UTC] svn@php.net
[2009-12-19 21:11 UTC] degeberg@php.net
[2010-01-12 02:58 UTC] simonokewode at hotmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 15:00:01 2025 UTC |
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().