Show/Hide Toolbars

EmEditor Help

Navigation: EmEditor Help > Macro Reference > Regex Object > Methods

EmEditor Macro Reference: Replace Method

Scroll Prev Top Next More
EmEditor Home - EmEditor Help - EmEditor Macro Reference - Regex Object

Replace Method

Searches the specified string for the regular expression and replace with the specified string. If the Global property is set, this method replaces all possible matches in the string.


strResult = reg.Replace( strText, strReplace );


strResult = reg.Replace( strText, strReplace )



Specifies a string to search for the regular expression.


Specifies a string to replace with.

Return Values

Returns the new string.



re = editor.regex;

re.Engine = eeExFindRegexOnigmo;

re.Pattern = "([A-Z0-9._%+-]+)@([A-Z0-9.-]+\\.[A-Z]{2,})";

re.IgnoreCase = true;

re.OnlyWord = false;

strOrg = "The email address is"

strNew = re.Replace( strOrg, "\\1 at \\2" );

if( strOrg != strNew ) {

   alert( strNew );



Set re = editor.regex

re.Engine = eeExFindRegexOnigmo

re.Pattern = "([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,})"

re.IgnoreCase = True

re.OnlyWord = False

strOrg = "The email address is"

strNew = re.Replace( strOrg, "\1 at \2" )

If strOrg <> strNew Then

   alert( strNew )

End If


Supported in EmEditor Professional Version 15.9 or later.

Copyright © 2003-2018 by Emurasoft, Inc.