Text - Find

Declaration

<AMTEXT TEXT="text" FIND="text" RESULTVARIABLEtextasdf" USERE="YES/NO" USECASE="YES/NO" INDEX="number" FOUNDTEXTVARIABLE="text" TOTALMATCHESVARIABLE="text" />

Related Topics   

Description

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

Practical usage

Commonly used to locate a word or phrase inside of a larger piece of text.

Parameters

General

Property Type Required Default Markup Description
Text Text Yes (Empty) TEXT="My name is Joe" The target body of text to be searched. As with every text parameter, if the data you wish to enter is contained in a variable, simply enter the variable name surrounded by percentage signs to resolve it to its contents at runtime (for example, %VarName%).
Find Text Yes (Empty) FIND="name" The portion of text to search for in the main body of text.
Case sensitive Yes/No No No USECASE="YES" Specifies whether the search performed should be case sensitive. If selected, the search is case sensitive. This parameter is disabled by default.
Regular expression Yes/No No No USERE="YES" Specifies whether the Find parameter is a regular expression. If disabled (default), the Find parameter contains literal text. If selected, the Find parameter contains a regular expression.
Populate variable with first index Text No (Empty) RESULTVARIABLE="varname" The name of an existing variable to receive the first position of the text to search for, if found.

Advanced

Property Type Required Default Markup Description
Starting at the following instance Number No 1 INDEX="2" Indicates that the target text should be searched starting at the following instance.  
Populate variable with found text Text No (Empty) FOUNDTEXTVARIABLE="varname" The name of an existing variable to receive the text that was found. This parameter is useful if regular expression is used to find text.
Total find count into variable Text No (Empty) TOTALMATCHESVARIABLE="varname" The name of an existing variable to receive the total instances found.

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task searches a body of text for the word "occurrence" and then displays the position of the first instance of the word, as well as the number of appearances of the word in a message dialog.

Copy
<AMVARIABLE NAME="indexVar" />
<AMVARIABLE NAME="totalInstances" />
<AMTEXT TEXT="This action finds each or every occurrence of a text pattern and places the result of each occurrence into a variable." FIND="occurrence" RESULTVARIABLE="indexVar" TOTALMATCHESVARIABLE="totalInstances" />
<AMSHOWDIALOG>The word 'occurrence' was found at position %indexVar%. The total number of times this word appeared was %totalInstances% times.</AMSHOWDIALOG>