Complex replacements

The simple replacements like \1 are often not enough. For example, you may want to convert the matching text to lowercase, insert the file name, or add width/height attributes to <img> tags. That's why Aba supports a complex replacement syntax:

Search forReplace toExplanation
</?[a-z]+ \(\0.toLower()) Convert all HTML tag names to lowercase
</?[a-z]+ \{\0.toLower()} Same

A complex replacement starts with a backslash, then an opening parenthesis, the expression itself, and a closing parenthesis. Instead of the parentheses, you can use braces {} for readability, especially when the expression contains another pair of parentheses.

For the complex replacements, Aba implements a scripting language that is similar to AWK and early JavaScript. This page gives an overview of the syntax and can serve as a quick reference; the next pages describe the supported functions in detail.

Data types

The following data types are supported

Comparison operators return true or false. Strings are automatically converted to numbers and vice versa. For an explicit conversion, use +str to convert to a number, ('' num) to convert to a string, and !!something to convert to a boolean, but this is rarely needed.

An empty string, false, null, 0, and -0 are false values. Everything else is a true value.

Global functions and variables

You can use the same \0, \1, etc. syntax inside the \( ) parentheses to refer to the found text and to the subexpressions:

Search forReplace toExplanation
\<(\w+) \1\> \(\1) Remove repeating words (the the will be changed to a single the)
\<(\w+) \1\> \1 Same, using the simple replacement syntax
\<(\w+) \1\> \(\1.toUpper()) Remove repeating words and convert them to uppercase (the the will be changed to THE)
\<(\w+) \1\> \{\1.toUpper()} Same, using braces for readability

The following global functions are also supported:


The list below shows all operators from highest to lowest precedence:

The next pages give more details on the behavior of math operations, concatenation, and logical operators.

The if ... else statement

If the condition is true, the if ... else statement returns the first value, otherwise it returns the default value. Multiple branches are possible:

String functions

The following string functions are supported:

File functions

The following file functions are supported:

This is a page from Aba Search and Replace help file.