PHP Developers Network http://forums.devnetwork.net/ |
|
Regular Expression is not working properly http://forums.devnetwork.net/viewtopic.php?f=38&t=33651 |
Page 1 of 1 |
Author: | telic [ Tue May 24, 2005 11:54 pm ] |
Post subject: | Regular Expression is not working properly |
Hi, I am doing an admin panel for flash using PHP and XML, here I am using regular expression to find and replace text in the xml file. This is the code I am using the find and replace operation $string = "<page><![CDATA[".$text."]]></page>"; $pattern = "/<page>(.)*<\/page>/"; $contents = preg_replace($pattern,$string,$contents); here “$text” content from textarea if I am giving small text content it’s working fine, if I am giving four or more lines then this regular expression is not working properly. please help me to rectify this issue.... Thanks in advance. |
Author: | anjanesh [ Wed May 25, 2005 12:16 am ] |
Post subject: | |
Try changing pattern to : $pattern = "/<page>(.*?)<\/page>/is"; Are you sure you are using preg_replace correctly ? Your replacement argument seems to be the subject. mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] ) |
Author: | Chris Corbyn [ Wed May 25, 2005 6:22 am ] |
Post subject: | |
![]() ![]() |
Author: | Chris Corbyn [ Wed May 25, 2005 6:28 am ] |
Post subject: | |
Yeah anjanesh is right. You need the "s" modifier because . (dot) will not match multiple lines by itself ![]() |
Page 1 of 1 | All times are UTC - 5 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |