EmEditor Home - EmEditor Help - EmEditor Macro Reference - Selection Object

Replace Method

Replaces a string in the document.


nFound = document.selection.Replace( strFind, strReplace, nFlags );


nFound = document.selection.Replace( strFind, strReplace, nFlags )



Specifies a string to search for.


Specifies a string to replace with.


Specifies a combination of the following values:

eeFindReplaceCase Matches cases.
eeFindReplaceEscSeq Uses escape sequences. Cannot be combined with eeFindReplaceRegExp.
eeFindReplaceOnlyWord Matches only whole words.
eeFindReplaceOpenDoc Searches all open documents in the same frame window.
eeFindReplaceQuiet Does not display a message on the status bar if no string is found.
eeFindReplaceRegExp Uses a regular expression for the searched string. Cannot be combined with eeFindReplaceEscSeq.
eeFindReplaceSelOnly Replaces only in the selection.
eeFindSaveHistory Saves the searched string for repeated search.
eeReplaceAll Replaces all at once.
eeReplaceSelOnly Replaces only in the selection. (same as eeFindReplaceSelOnly)

Return Values

Returns the number of replaced strings if eeReplaceAll is specified. Otherwise, returns 1 if found, or 0 if not.


Supported on EmEditor Professional Version 4.00 or later.

Copyright 2003-2015 by Emurasoft, Inc.