Find and Replace Plus

Developer

Laisvunas

3rd Party (Free)

5 downloads (last 90 days)


EE Version Support

  • ExpressionEngine 1.x
  • ExpressionEngine 2

Compatibility

If an item is crossed out, it might be untested, not applicable or incompatible. Contact the developer to be sure.

  • Updater
  • Multi Site Manager
  • Stand Alone Entry Form
  • Low Variables
  • Content Elements
  • Better Workflow
  • Matrix
  • Grid
  • Webservice
  • Publisher

Requirements

  • jQuery for the Control Panel

Add-On Type(s)

Plugin

Tags

Find and Replace Plus will find and replace strings. Works pretty much the same as the php str_replace() function and preg_replace() function.

This plugin works pretty much the same as the php str_replace() function:
http://www.php.net/manual/en/function.str-replace.php and the preg_replace() function:
http://www.php.net/manual/en/function.preg-replace.php

ExpressionEngine strips the white space from the beginning and the end of each parameter. Because of this,
if you want to replace something with a space, use the string “:SPACE:” instead.
If you want to use a double quote in a parameter value, use the string “:QUOTE:” instead.
If you want to use slash in a parameter value, use the string “:SLASH:” instead.
If you want to use left curly brace in a parameter value, use the string “:LD:” instead.
If you want to use right curly brace in a parameter value, use the string “:RD:” instead.

PARAMETERS

1) find - Required. Allows you to specify what strings should be found. You can specify
several strings using pipeline character.

2) replace - Optional. Allows you to specify what strings should replace the strings found.
You can specify several strings using pipeline character. In case you leave this parameter undefined,
the strings found will be replaced with empty string.

3) multiple - Optional. Allows you to specify if you seach for several strings (value “yes”), or
for just one string (value “no”). Default is “no”.

4) casesensitive - Optional. Allows you to specify if you want to do casesensitive replace (value “yes”)
or caseinsensitive replace (value “no”). Default is “yes”.

5) regex - Optional. Allows you to specify regular expression. The value of this param must be “yes” in case the value
of the param “find” is a regular expression.

6) regex_limit - Optional. The maximum possible of regex replacements. Default value is -1 (no limit).

VARIABLE PAIRS

{replace_area}{/replace_area} - Optional. allows you to specify area in which the plugin should do find-replace
operations.

Each parameter can be used not only inside exp:replace_plus tag but also inside {replace_area}
variable pair. In case parameter is defined both inside exp:replace_plus tag and inside {replace_area}
variable pair, the value of the latter overrides the value of the former.

{replace_area}{/replace_area} can be nested. This feature can be handy in cases initial find-replace produces
unwanted results. Those unwanted results can be corrected by wrapping one variable pair inside another pair having
different “find” and “replace” parameters.

EXAMPLES

# Replace A with B:

{exp:replace_plus find="you" replace="we"}
  text you want processed
{/exp:replace_plus}

Result: text we want processed

# Replace A with B inside {replace_area} and {/replace_area} variable pair:

{exp:replace_plus find="you" replace="we"}
text you want processed
{replace_area}
text you want processed
{/replace_area}
text you want processed
{/exp:replace_plus}

Result:

text you want processed
text we want processed
text you want processed

# Replace A with B inside several {replace_area}{/replace_area} variable pairs:

{exp:replace_plus}
text you want processed
{replace_area find="you" replace="we"}
text you want processed
{/replace_area}
{replace_area find="you" replace="I"}
text you want processed
{/replace_area}
text you want processed
{/exp:replace_plus}

Result:

text you want processed
text we want processed
text I want processed
text you want processed

# Replace A with B inside {replace_area}{/replace_area} variable pair and
correct unwanted results by wrapping it within another {replace_area}{/replace_area} variable pair:

{exp:replace_plus}
text you want processed
{replace_area find=":SPACE:>:SPACE:" replace=">"}
{replace_area find="<|>" replace="<|>"}
{if total results > 0}
<p>text you want processed</p>
{/if}
{/replace_area}
{/replace_area}
text you want processed
{/exp:replace_plus}

Result:

text you want processed
<p>text you want processed</p>
text you want processed

# Replace A with a space:

{exp:replace_plus find="o" replace=":SPACE:"}
  text you want processed
{/exp:replace_plus}

Result:
text y u want pr cessed


# Replace a space with nothing

{exp:replace_plus find=":SPACE:"}
  text you want processed
{/exp:replace_plus}

Result:

textyouwantprocessed


# Replace A, B and C with D:

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

Result:

tXxt yXX wXnt prXcXssXd


# Replace A, B and C with X, Y and Z:

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

Result:

words we have processed

# Regular Expression find and replace:

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

Result:

* * * *

# Regular Expression find and replace with backreference:

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

Result:

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

Note: if you want to replace something with nothing, best is to omit the replace parameter altogether.
If you want to find multiple strings, always use the multiple=“yes” parameter, or else it will search
for the literal string, including vertical bars. The multiple parameter has no effect when using a
regular expression find and replace.

This function is case sensitive by default. Use the parameter casesensitive=“no” to ignore case, both
for a normal as for a regular expression find and replace.

When using regex=“yes” it is recommended that you set your Debug Preference (Admin > System Preferences
> Output and Debugging Preferences) to 1, so Super Admins can make sure their regular expressions
aren’t generating server errors.

Download Find and Replace Plus

EE Support Downloads Add-On Version Release Date
Not Specified Download 1.4.1
Not Specified Download 1.4.1

This entry was created June 11, 2009, 11:27 am.
This entry was last updated September 2, 2011, 12:24 am.

Disclaimer: Information about ExpressionEngine add-ons is provided as a service to you, the user, and every member of the ExpressionEngine community. devot:ee is not responsible if you hose, mangle, wreck, or otherwise destroy your EE website by installing an add-on that you found out about at this site, regardless of its rating, Favorites status, commercial or free status, or general popularity. Caveat EEmptor!

Returns: devot:ee has a 30-day return policy on all commercial add-ons sold through devot-ee.com. If you need to return an add-on, do not go to the developer or the developer's site, but rather visit our returns page at https://devot-ee.com/returns to initiate your return. If you have questions, email support@devot-ee.com.

1 Review:

ahebrank 07.30.14

ahebrank
Rating - {addon_rating_average}

Needed a way to globally fix client-entered URLs and this did just that.