Powerful Patterns for Generating Regular Expressions About RegexMagic's Patterns 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 digit between 1 and 9, or a digit 1 followed by a digit between 0 and 2: [1-9]|[12][0-2]. 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. | |
Patterns Available in RegexMagic 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. Unicode Characters  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. Basic Characters  Match ASCII characters. You can type or paste in individual characters, or select basic character categories in the list. Character Masks  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. List Of Literal Text  Type in or paste in a list of text to generate a regular expression that matches one of the lines of text. Literal 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. Number  Match floating point numbers or monetary values. RegexMagic provides a wide range of options for signs, decimals, separators, exponents, currency signs and codes, etc. | |
Integer  Match integer numbers in decimal, hexadecimal, octal and/or binary notation. Date And Time  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. |   | Integer pattern | |
Email Address  Match an email address. You can restrict the email address to certain user names and/or domain names. URL  Match an Internet address. RegexMagic provides various options to match only specific URLs. Credit Card Number  Match a credit card number issues by one or more of the world's major credit card companies. National ID  ID card numbers, social security numbers, license plate numbers, etc. used in particular countries. VAT Number  Value Added Tax numbers used in the European Union. Regular Expression  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. Easily Create Regexes with RegexMagic |