Pasting Date Parts into Forms (AutoHotkey RegEx Tips Part 4)

In Most Data Fields, You’ll Find It Simple to Paste Text or Numbers, But Inserting a Parsed Date Often Requires Extra Steps—Plus How to Change Date Paste Action Based on the Active Window Title

In the first three blogs of this RegEx series, I used Regular Expressions (RegEx) to identify and parse data prior to any paste operations. In this blog, I use a RegEx to identify and parse dates during the multi-part date paste operation. I use the previously introduced \d wild card (any numeric digit zero through nine) and the optional match modifier (the question mark ?), plus, I introduced how to create a selection list of possible matches by using a range of options (in this case, a forward slash, a dash, or a dot [/\-.] as date separators).

*          *          *

Cover 200When working with forms, dates often use three separate data entry fields—one for the month, one for the day, and one for the year. (In the UK, they swap it around to day/month/year.) In some forms, you need to enter a forward slash (/) to jump to the next entry item. Sometimes the form automatically jumps to the next field after entering two digits. In many Web pages, you need to tab between each data entry area. Sometimes, sending the entire copied date as a single string works.

Since I wrote the MultiPaste.ahk script to respond to a particular personal finance program, I set it up to Send the date delimited with slashes. If you want to do something similar for a different software package or Web page, then you may need to tailor the script. This blog shows you how to do that. Continue reading

Removing Excess Tabs and Spaces with RegEx Greed (AutoHotkey RegEx Tips Part 3)

After Parsing Selected Table Data or One-Line Street Addresses for Unique Paste Operations, We Prevent Blank Paste Items from Appearing in the MsgBox Window by Using RegEx Greed to Remove Any Extra Tab Characters

In the first two parts of this series, I introduced a couple of common Regular Expressions (RegEx) wild cards for finding unknown characters (the needle) in a larger string of text (the haystack). In “Finding US Zip Codes (AutoHotkey RegEx Tips Part 1),” I discussed the \d expression (representing any single numeric digit) which you can also identify with the range [0-9] or the expression set (0|1|2|3|4|5|6|7|8|9).

In “Finding UK Postal Codes (AutoHotkey RegEx Tips Part 2),” I introduced the wild card \w as the RegEx symbol for matching any alphanumeric character (upper or lower case) and the ten digits (plus underline mark)—the equivalent of the range [a-zA-Z0-9_]. In both blogs, I used the /s wild card to locate a space in front of either the US zip code or UK postal code.

This time I use \s in combination with `t to remove extra tab delimiters (e.g.`t`t) which insert blank lines in the MultiPaste.ahk script’s MsgBox command window.

Continue reading

Finding UK Postal Codes (AutoHotkey RegEx Tips Part 2)

By Comparison, UK Postal Codes Offer a Greater Challenge Than US Zip Codes When Writing Regular Expressions (RegEx)

UKPostalCode
Note that a single space appears between “Birmingham” and the “B5 5QD” postal code. Without special recognition of the UK postal codes, the MultiPaste.ahk script won’t create a separate paste item.

In the previous blog (“Finding US Zip Codes (AutoHotkey RegEx Tips Part 1)“), I began this mini-tutorial series on AutoHotkey Regular Expressions (RegEx) with a technique for parsing US zip codes from street addresses. For the MultiPaste.ahk script to work best (“Parsing and Pasting One-Line Street Addresses (AutoHotkey Multi-Paste Trick)“), I needed any zip code to appear as a separate paste item in the MultiPaste MsgBox. The parsing problem occurs because most one-line address formats only use as a delimiter the space character (no comma or newline) between the state and zip code. The same holds true for UK postal codes.

Cover 200Last time, I pointed out how the string functions—InStr() and StrReplace()—require exact search characters while the Regular Expressions functions—RegExMatch() and RegExReplace()—can use a variety of wild cards to represent characters. In fact, the various different ways to express wild cards cause a degree of confusion. In this blog, I introduce the \w alphanumeric wild card and the question mark modifier (?) to create optional matches. Continue reading

Finding US Zip Codes (AutoHotkey RegEx Tips Part 1)

Powerful Regular Expressions (RegEx) Perform Minor Computing Miracles—This Part 1 Uses Extracting US Zip Codes from Street Addresses to Introduce Regular Expressions as Merely a Set of Confusing Wildcards

In my last blog, “Parsing and Pasting One-Line Street Addresses (AutoHotkey Multi-Paste Trick)“, I added one-line street addresses to my MultiPaste.ahk script. That short AutoHotkey app uses a few Regular Expressions (RegEx) to identify and isolate key information:

  1. Cover 200Five-digit US zipcodes.
  2. UK postal codes.
  3. Remove excess tab characters in the results.
  4. Identify date formats.

I used RegEx functions for these problems because the basic string functions just didn’t offer the power needed without convoluted coding. RegEx provides fairly simple solutions (although possibly confounding to the neophyte).

Continue reading