NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to match a pattern to the end of a line


Joined: 11 May 2011
Posts: 1
Reply with quote
In every editor I have ever used it is pretty easy to do a search and replace on wild cards so that you can have inexact matches.

There are also special characters used in a search to match to the end of a line.

so if I have a source file with

private $var1 = 12;
private $var2 = 11;
private $var3 = array();


I can trivially search and replace from var*> (brief)- or var*$ (dev studio)

which doesn't work in PHPED. (with regular expressions checked)

I emailed support and they said the $ should work but either they didn't under understand the question of it just doesn't work on my office machine or my home machine.

Any thoughts?

thanks,
Joel
View user's profileFind all posts by mathisonSend private message


Joined: 30 Aug 2010
Posts: 8
Reply with quote
Hi,
Can you be a bit more specific?
Which part you want to change and to what?
View user's profileFind all posts by BurakUedaSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
PhpED uses PCRE (Perl Compatible) regular expression syntax. Try searching for var\w* and that will search for var followed by word characters with repetition. It should then stop at the next space, =, bracket, etc.

To match to a specific end character such as the ; (so you don't include comments) then use var.*; and to match to end of line (including any comments) you can just use var.* and the greedy repitition will go to the end of the line.

I would probably be inclined to use a variable prefix if possible, such as \$var\w* so that I didn't find things that contain var, such as var_dump(). Wink
View user's profileFind all posts by plugnplaySend private message
How to match a pattern to the end of a line
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