Replace Text Action Icon

Replace Text

Declaration

<AMREPLACE TEXT="test" FIND="test" REPLACE="test" RESULTVARIABLE="text [variable name]" USERE="YES" USECASE="YES" INDEX="6" MAXMATCHES="6" TOTALMATCHESVAR="text [variable name]">

See Also

Convert Case | Find Text | Format Date/Time | Get Subtext | Insert Text | Pad Text | Replace Text | Trim Text

Description

Finds and replaces each or every occurrence of a text pattern and places the result into a variable.  Regular expressions may be used for added power and flexibility.

Practical Usage

Generally used to find and replace a word or phrase inside of a larger piece of text.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Text

Text

Yes

(Empty)

 

TEXT="My Name is Joe"

The target text to be searched.

Find

Text

Yes

(Empty)

FIND="Joe"

The text to search for.

Replace With

Text

Yes

(Empty)

REPLACE="Jim"

The text to replace the found text with.

Case Sensitive

Yes/No

No

No

USECASE="YES"

If set to YES , specifies that the search performed should be case sensitive. This parameter is set to NO by default.

Regular Expression

Yes/No

No

No

USECASE="YES"

If set to YES, specifies that the FIND parameter contains a regular expression. If set to NO (default), the Find parameter contains literal text.

Populate variable with result

Text

Yes

(Empty)

RESULTVARIABLE="varname"

The name of the variable to receive the new text after replacement.

 

Advanced Tab

Property

Type

Required

Default

Markup

Description

Starting at the following instance

Number

No

1

INDEX="5"

Specifies at what instance text replacement should be applied.

Maximum replacements

Number

No

0

MAXMATCHES="6"

Specifies the maximum number of replacements that should be made. If 0 (default) is specified, all instances of the found text will be replaced.

Total replacement count into variable

Text

No

(Empty)

TOTALMATCHESVAR="varname"

The name of the variable to receive the total number of replacements that were made.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: Simple Replace Text Task

 

<AMVARIABLE NAME="sourcedata">AutoMate adds power, speed, flexibility and intelligence.</AMVARIABLE>

<AMVARIABLE NAME="newdata"></AMVARIABLE>

<AMREPLACE TEXT="%sourcedata%" FIND="speed" REPLACE="sexiness" RESULTVARIABLE="newdata" />

<AMSHOWDIALOG>BEFORE: %sourcedata%

AFTER: %newdata%</AMSHOWDIALOG>

 

↑ [Top of Page]