A Beginner’s Guide to Using Regular Expressions in AutoHotkey Front Cover

A Beginner’s Guide to Using Regular Expressions in AutoHotkey


AutoHotkey is a powerful scripting language for Windows XP, Windows Vista, Windows 7, Windows 8, and Windows 10. If you don’t already use AutoHotkey with your Windows computers, then you should start. The language is simple, yet powerful. Best of all, it’s free to use.

This “Beginner’s Guide to Using Regular Expressions in AutoHotkey” is not a beginning level AutoHotkey book, but an introduction to using Regular Expressions in AutoHotkey (or most other programming languages). To get the most from this book you should already have a basic understanding of AutoHotkey (or another programming language). Regular Expressions (RegEx) are a powerful way to search and alter documents without the limitations of most of the standard matching functions. At first, the use of RegEx can be confusing and mysterious. This book clears up the confusion with easy analogies for understanding how RegEx works and examples of practical AutoHotkey applications. “Regular Expressions in AutoHotkey” will take you to the next level in AutoHotkey scripting while adding more flexibility and power to your Windows apps.

Regular Expressions (commonly called RegEx or RegExp) in AutoHotkey is not a beginning level script writing topic and there certainly is nothing regular about Regular Expressions. Jack spent a good bit of time exploring the programming tools and has developed a healthy respect for RegEx flexibility and power. Many (including Jack) have avoided using RegEx due to its enigmatic code which at times appears almost incomprehensible. It’s not like normal program code with If-Then-Else statements and Loops. Writing a RegEx is not merely a matter of following a logical sequence. It often requires a non-linear look at the problem. Jack’s found that what helps him most is the analogy he pictures in his brain pan. That image gives a basis for what a RegEx is trying to do. (“Try” is a good word when describing RegExs. Whereas the usual programming either works or doesn’t work, RegEx “tries” to find pattern matches. If none are found, it moves on.)

The chapters in this book are grouped by their place in developing a deeper understanding of Regular Expressions while emphasizing the practical application of RegExMatch() and RegExReplace()—the two primary AutoHotkey Regular Expressions functions.The first three chapters are the most important for getting a quick start on how to view and understand Regular Expressions and the AutoHotkey RegEx functions, while the remaining chapters can be studied in almost any order as they each demonstrate one or more practical RegEx applications—i.e. finding double words in text (Chapter Five); fixing mistyped word contractions (Chapter Six); swapping two word in any text editing (Chapter Seven); extracting IP addresses from text, then extracting the geographic location of each from the Web (Chapter Eight); stripping HTML tags from source code leaving only pure text (Chapter Nine); extracting links from a Web page and saving them to a text file (Chapter Ten); and validating e-mail addresses (Chapter Eleven). The final two chapters address slightly more advanced, but important topics, look-ahead and look-behind assertions, plus RegEx Properties p{xx}.

If you’re a novice script writer, you may be better served by starting with a beginning book or tutorial. If you’re a more experienced programmer, then “Regular Expressions in AutoHotkey” may act as a reference for how and when to use them in your AutoHotkey applications.

Table of Contents

Chapter One: Understanding the Mysteries of Regular Expressions (RegEx) in AutoHotkey
Chapter Two: An Introduction to Easy Regular Expressions (RegEx) in AutoHotkey
Chapter Three: AutoHotkey RegExMatch() Versus RegExReplace()
Chapter Four: Simplified Regular Expressions in AutoHotkey
Chapter Five: Eliminating Double Words with RegEx
Chapter Six: Fixing Contractions with RegEx
Chapter Seven:A Simple Beginner’s Trick for Swapping Letters and Words
Chapter Eight: A Simple Way to Find Out Where in the World That IP Address Is Located
Chapter Nine: Stripping Out HTML Tags
Chapter Ten: An App for Extracting Web Links from Web Pages
Chapter Eleven: Verifying E-mail Addresses with AutoHotkey
Chapter Twelve: Look-Ahead and Look-Behind RegEx Mysteries
Chapter Thirteen: Using RegEx Property Symbols

To access the link, solve the captcha.