The main stumbling block for many people is that there is nothing in the regular expression syntax that allows you to work with dates or numbers or email addresses or any other concept that most people would instantly recognize. Regular expressions only deal with characters, one at a time. To a regular expression, 123,456.78 is a sequence of digits and punctuation characters, just like 2009-07-19. That makes it very hard to deal with higher-level concepts. Instead of saying “match a number between 1 and 12”, you have to say “match a word boundary and then either match a digit between 1 and 9 or matched a digit 1 followed by a digit between 0 and 2 all of which followed by another word boundary: \b([1-9]|1[0-2])\b. This quickly gets unwieldy for longer numbers or more complex combinations such as dates.
With RegexMagic you can work directly with higher-level concepts such as dates, numbers, or email addresses. Using the integer pattern, you can tell RegexMagic to match a number between 1 and 12. Using the date pattern, you can ask RegexMagic for a regex to match a date between yesterday and last week. Let RegexMagic do the hard work of translating those concepts into the character combinations that regular expressions work with.
Just like regular expressions allow you to match sequences of characters (e.g. abc) and alternatives (e.g. abc|def), RegexMagic allows you to match sequences and alternatives of RegexMagic patterns, in any combination. To match a comma-delimited list of 3 numbers, you’d use a number pattern, a literal text pattern matching a literal comma, another number pattern, another literal text pattern, and a third number pattern. You could set different options for the number patterns, or tell RegexMagic to make them all the same. By combining as many patterns as you need, you can generate a regular expression that matches anything you want. In situations where RegexMagic doesn’t provide a convenient pattern, you can use the “Unicode characters” and “basic characters” patterns to fall back to spelling things out based on characters, as regular expressions normally do.
These are the most important patterns available in RegexMagic for generating regular expressions. The screen shots show the settings that you can make specific to each pattern. Some of the patterns have another screen shot in the right margin that expands when you hover the mouse over it. The screen shots in the margin show how the pattern settings appear in RegexMagic.
Match Unicode characters. You can type or paste in individual characters, or select Unicode character categories in the list.
If RegexMagic doesn’t have a pattern for (a part of) the text you’re trying to match, you can always use one or more “Unicode characters” patterns to describe that text.
Match ASCII characters. You can type or paste in individual characters, or select basic character categories in the list.
Require this field to match one of a list of simple character masks. These masks are similar to the masks used by the masked edit controls that many development tools offer to make it easier for the user to enter specific numbers or codes. E.g. (999) 999-9999 could be the mask for a North American phone number.
Type in or paste in a list of text to generate a regular expression that matches one of the lines of text.
Always match the same piece of text. Though this pattern is not very useful on its own (as you could just run a literal text search), it is very handy in combination with the other patterns when the text you want to match includes fixed labels or delimiters.
Always match the same block of bytes. Though this pattern is not very useful on its own (as you could just run a literal bytes search), it is very handy in combination with the other patterns when the bytes you want to match include fixed sequences or delimiters.
Match any of the ASCII control characters you select in the list.
Match floating point numbers or monetary values. RegexMagic provides a wide range of options for signs, decimals, separators, exponents, currency signs and codes, etc.
Match integer numbers in decimal, hexadecimal, octal and/or binary notation.
Match a date and/or a time. You can use simple date and time format specifiers to indicate which date and/or time formats you want to allow. When spelling out day and month names, you can type in the names in the language that your regex should support.
Match an email address. You can restrict the email address to certain user names and/or domain names.
Match an Internet address. RegexMagic provides various options to match only specific URLs.
Match a country code or country name as defined in the ISO 3166 standard. You can restrict the pattern to the codes and/or names of specific countries.
Match the name and/or code of a state or province from a list of specific states or all states or provinces from specific countries.
match a currency code as defined in the ISO 4217 standard. You can restrict the pattern to specific currencies.
Match a credit card number issues by one or more of the world’s major credit card companies.
ID card numbers, social security numbers, license plate numbers, etc. used in particular countries.
Value Added Tax numbers used in the European Union.
Match an IPv4 internet address or a range of addresses in dotted decimal notation or as a decimal or hexadecimal number.
Match a Globally Unique Identifier.
Use an arbitrary regular expression. This pattern is useful for using regular expressions you’ve obtained from elsewhere with RegexMagic. RegexMagic can interpret all the regular expression flavors for which it can generate regular expressions.
If two or more parts of your regular expression fit the same pattern then you need to specify that pattern only once. With the “pattern used by another field” pattern you can reference this pattern as many times as you want.
Make one part of your regular expression match exactly the same text as was matched by another part of your regular expression.
Allow part of your regular expression to match any text. Since “anything” usually isn’t truly anything this pattern provides various options to make sure the “anything” part of your regex doesn’t overstep its boundaries.