Understanding regular expressions

When dealing with source code and HTML files, you often need to rearrange the fragments of text or to alter them in a complex way, which is impossible to do with a simple textual search and replace. Regular expressions can help you to perform such complex replacements.

What is a regular expression?

Regular expression (regex for short) is a pattern for text matching. It uses special characters (metacharacters) that can match a letter, a digit, several digits and many others. Regular expression is a powerful tool for searching and modifying your text files.

If you ever worked in a command-line environment or a file manager, you already have used a simple kind of regular expressions. It's called file mask: to specify all files with txt extension, you type *.txt, to specify all file names beginning with report, you type report*.*, and so on.

General questions about regular expressions

Should I know programming to understand regular expressions?

No, you don't need to have any background in programming to learn regular expressions. The regular expression concept is very different from a typical programming language, so a programmer would hardly have any advantage over an advanced user if both never used regular expressions before. With some practice, both people can learn how to work with them.

However, regular expressions are implemented in many programming languages, including C#, Perl, Python, and AWK. If you have used regexes in these languages, you will find Aba's implementation familiar. If you did not, you could view understanding regular expressions as the first step in learning Perl or another powerful programming language.

In the following parts of this manual, you will learn about different metacharacters and their usage.

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