User Tools

Site Tools


action:Search_using_Regular_Expression

**This is an old revision of the document!**

The Search using Regular Expression action allows you to search a clipboard, variable, a file or some text for a regular expression and capture what you find to one or more variables. This can be very useful for splitting apart the contents of a variable.

Select the source to search to search using the Search pop-up.

You can search for Regular Expression, matching case sensitively or ignoring the case.

Select whether or not to match the case from the using Regular Expression pop-up. Then enter the text to search for in the text area.

Select where to save results with the and save capture groups to Variables section. The entire match, and each capture group (enclosed in brackets) can be saved to variables. Depending on the nature of your search you may simply be presented with an All option, or with the opportunity to save multiple results to multiple variables.

If the search fails, by default (7.1+) the action will abort the macro and notify you of the failure. The destination variables will not be modified. You can turn off aborting the macro and/or notifying you in the gear menu (the destination variables will still not be modified in this case).

Examples:

  • Use a regular expression to search through a product price list and save only certain parts of it.

Given a line like

SKU1234 Widget 1 $12.95

this could look like the following:

Search for: (SKU\d{4})\t(.+)\t(.+)

And capture: the first and third bracketed items to save only the SKU number and the price.

To work through a list you would need to include a loop or repeat of some kind.

Which results in:

See Also

Actions

Topics

Forum

action/Search_using_Regular_Expression.1504771878.txt.gz · Last modified: 2017/09/07 04:11 by peternlewis