PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Dec 07, 2019 1:09 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue May 24, 2005 11:54 pm 
Offline
Forum Newbie

Joined: Tue May 24, 2005 8:47 am
Posts: 1
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 12:16 am 
Offline
DevNet Resident
User avatar

Joined: Sat Dec 06, 2003 10:52 pm
Posts: 1679
Location: Mumbai, India
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] )


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 6:22 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
:arrow: Moved to Regex :?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 6:28 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Yeah anjanesh is right. You need the "s" modifier because . (dot) will not match multiple lines by itself :wink:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group