Plugin update: Find and Replace
Posted: 13 December 2005 04:26 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  376
Joined  10-18-2004

My first plugin for EE has had an update. Current version is 1.1. Download the plugin from my site. Usage examples can be found there, too.

ETA: Current version is 1.3. Scroll down for details.

 Signature 

Low: the Pro Network member who brought you the File Manager Module, Yearly Archives Plugin, Find & Replace Plugin, Akismet Combo, and more…

Profile
 
 
Posted: 13 December 2005 04:54 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  514
Joined  04-24-2004

This is such a handy plugin, thanks for releasing it. What has changed in 1.1?

 Signature 

lukestevensdesign.com · Design 2.0 · Pro Network member

Profile
 
 
Posted: 13 December 2005 05:03 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  376
Joined  10-18-2004
Luke S. - 13 December 2005 04:54 AM

What has changed in 1.1?

First of all, you can now search for spaces or replace strings with spaces, by using find=“SPACE” or replace=“SPACE”.

Secondly, the plugin now supports multiple replacements, just like the php str_replace function. Example:

{exp:replace find="a|e|i|o|u" replace="X" multiple="yes"}
  text you want processed
{
/exp:replace}

Result: tXxt yXX wXnt prXcXssXd

Or take this one step further:

{exp:replace find="text|you|want" replace="words|we|have" multiple="yes"}
  text you want processed
{
/exp:replace}

Result: words we have processed

And to finish things off, if you’re running PHP 5 or higher, then you can use the parameter casesensitive=“no” to ignore case.

 Signature 

Low: the Pro Network member who brought you the File Manager Module, Yearly Archives Plugin, Find & Replace Plugin, Akismet Combo, and more…

Profile
 
 
Posted: 13 December 2005 12:20 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  376
Joined  10-18-2004

Thanks to some helpful input from Paul, the casesensitive=“no” parameter is now available for PHP 4 and higher, thus pushing the version number to 1.2. Go get it! (also available at plugins.pmachine.com)

 Signature 

Low: the Pro Network member who brought you the File Manager Module, Yearly Archives Plugin, Find & Replace Plugin, Akismet Combo, and more…

Profile
 
 
Posted: 24 November 2006 08:43 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  376
Joined  10-18-2004

I upgraded this plugin to version 1.3:

- Fixed a bug concerning replacing ampersands
- Use the string QUOTE for finding/replacing double quotes ("), useful for adding double quotes as a parameter value
- Added a new feature: regular expression find & replace

Examples for RegEx:

{exp:replace find="\w+" replace="*" regex="yes"}
text you want processed
{
/exp:replace}

Result
: * * * *

Regular Expression find and replace with backreference:

{exp:replace find="<a[^>]*href=QUOTE(.+)QUOTE[^>]*>(.*)<\/a>" replace="$2 ($1)" regex="yes"}
<a href="http://www.foo.com/">text</a> you want <a href="http://www.bar.com/">processed</a>
{/exp:replace}

Result
: text (http://www.foo.com/) you want processed (http://www.bar.com/)

Want categories listed grammatically correct? This example will replace the last comma with ” and”:

{exp:replace find=", ([^,]+)$" replace="&nbsp;and $1" regex="yes"}{categories backspace="1"}
<a href="{path=/}" title="View all posts in {category_name}">{category_name}</a>,
{/categories}{/exp:replace}.

 Signature 

Low: the Pro Network member who brought you the File Manager Module, Yearly Archives Plugin, Find & Replace Plugin, Akismet Combo, and more…

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66394 Total Logged-in Users: 26
Total Topics: 84721 Total Anonymous Users: 16
Total Replies: 454716 Total Guests: 171
Total Posts: 539437    
Members ( View Memberlist )