NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[PhpED 4.6] Regular Expression replace with newlines


Joined: 14 Jun 2006
Posts: 14
Location: Eindhoven, Netherlands
Reply with quote
Assume I have this piece of code:
Code:
<?php
$error = true;
$message = "An error occured."
?>


I used this in some old script of mine, and I used it a lot, so it would be wise to replace this with trigger_error("Blabla");
That's why I made this regex to apply it to all my php-files in some project:

Code:
\$error[\s]*=[\s]*true;[\s]*\n[\s]*\$message[\s]*=[\s]*["'](.*?)["'];


But it doesn't work! Although I'm pretty sure it's correct. When I try:

Code:
\$error[\s]*=[\s]*true;

and
Code:
\$message[\s]*=[\s]*["'](.*?)["'];


seperately they work fine. I also tried using [.]* and [\s]*\r[\s]* and lots of other variants instead of [\s]*\n[\s]* but I can't get them to work. Is there a known bug with regexes in the search and replace of PhpED? Or am I making a wrong turn somewhere?
View user's profileFind all posts by MeAngrySend private messageVisit poster's websiteMSN Messenger
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Yet, search/replace can't handle newlines because it matches editor content line by line.
But we'll enhance it one day.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 14 Jun 2006
Posts: 14
Location: Eindhoven, Netherlands
Reply with quote
Would be nice then maybe to mention that in the manual, because now the Regular Expression help also states the use of \n and \r which can be kind of confusing. Wink
View user's profileFind all posts by MeAngrySend private messageVisit poster's websiteMSN Messenger
[PhpED 4.6] Regular Expression replace with newlines
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 vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic