Regular Expression (Regex) Design and Test Tool for .NET - Rad Software Rad Software Regular Expression Designer is a free download that helps programmers learn, develop and test Regular Expressions. It is an interactive Windows application that is designed to be simple and easy to use. Features The Regex match results are listed in a tree with levels for Matches, Groups and Captures. .NET Framework 1.1/2.0 Required The Regular Expression Designer is requires the .NET Framework to be installed before it will run. Download Download Rad Software Regular Expression Designer v1.4 (~209 KB) If you have found the Regular Expression Designer useful and you would like to make a donation please use this PayPal button. The Regex Designer is free and there is no obligation to donate :-) Updated to Version 1.4 The Regular Expression Designer has been updated to v1.4. Regex is run in another thread so long running expressions can be cancelled. Changes in v1.1 All text boxes (Input text, Regular expression, Replace expression and Replace results) are no longer limited to 32k.
Finding or Verifying Credit Card Numbers With a few simple regular expressions, you can easily verify whether your customer entered a valid credit card number on your order form. You can even determine the type of credit card being used. Each card issuer has its own range of card numbers, identified by the first 4 digits. You can use a slightly different regular expression to find credit card numbers, or number sequences that might be credit card numbers, within larger documents. This can be very useful to prove in a security audit that you're not improperly exposing your clients' financial details. We'll start with the order form. Stripping Spaces and Dashes The first step is to remove all non-digits from the card number entered by the customer. To remove all non-digits from the card number, simply use the "replace all" function in your scripting language to search for the regex [^0-9]+ and replace it with nothing. If you're wondering what the plus is for: that's for performance. Validating Credit Card Numbers on Your Order Form
Regular Expressions Reference The regular expressions reference on this website functions both as a reference to all available regex syntax and as a comparison of the features supported by the regular expression flavors discussed in the tutorial. The reference tables pack an incredible amount of information. To get the most out of them, follow this legend to learn how to read them. The tables have six columns for each regular expression feature. The final two columns indicate whether your two chosen regular expression flavors support this particular feature. When this legend says "all versions" or "no version", that means all or none of the versions of each flavor that are covered by the reference tables: For the .NET flavor, some features are indicated with "ECMA" or "non-ECMA". For the std::regex and boost::regex flavor there are additional indicators ECMA, basic, extended, grep, egrep, and awk. For the PCRE2 flavor, some replacement string features are indicated with "extended".
Example: Matching Floating Point Numbers with a Regular Expression This example shows how you can avoid a common mistake often made by people inexperienced with regular expressions. As an example, we will try to build a regular expression that can match any floating point number. Our regex should also match integers and floating point numbers where the integer part is not given. We will not try to match numbers with an exponent, such as 1.5e8 (150 million in scientific notation). At first thought, the following regex seems to do the trick: [-+]? Spelling out the regex in words makes it obvious: everything in this regular expression is optional. Not escaping the dot is also a common mistake. When creating a regular expression, it is more important to consider what it should not match, than what it should. Here is a better attempt: [-+]? This is a far better definition. We can optimize this regular expression as: [-+]? If you also want to match numbers with exponents, you can use: [-+]? Did this website just save you a trip to the bookstore?
Regex Tutorial - \b Word Boundaries The metacharacter \b is an anchor like the caret and the dollar sign. It matches at a position that is called a "word boundary". This match is zero-length. There are three different positions that qualify as word boundaries: Before the first character in the string, if the first character is a word character. Simply put: \b allows you to perform a "whole words only" search using a regular expression in the form of \bword\b. Exactly which characters are word characters depends on the regex flavor you're working with. Most flavors, except the ones discussed below, have only one metacharacter that matches both before a word and after a word. Since digits are considered to be word characters, \b4\b can be used to match a 4 that is not part of a larger number. \B is the negated version of \b. Looking Inside The Regex Engine Let's see what happens when we apply the regex \bis\b to the string This island is beautiful. \b cannot match at the position between the T and the h. Tcl Word Boundaries
Example: Matching Numeric Ranges with a Regular Expression Since regular expressions deal with text rather than with numbers, matching a number in a given range takes a little extra care. You can't just write [0-255] to match a number between 0 and 255. Though a valid regex, it matches something entirely different. [0-255] is a character class with three elements: the character range 0-2, the character 5 and the character 5 (again). This character class matches a single digit 0, 1, 2 or 5, just like . Since regular expressions work with text, a regular expression engine treats 0 as a single character, and 255 as three characters. The regex [0-9] matches single-digit numbers 0 to 9. [1-9][0-9] matches double-digit numbers 10 to 99. Matching the three-digit numbers is a little more complicated, since we need to exclude numbers 256 through 999. 1[0-9][0-9] takes care of 100 to 199. 2[0-4][0-9] matches 200 through 249. Putting this all together using alternation we get: [0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5].
Regular Expression Examples Below, you will find many example patterns that you can use for and adapt to your own purposes. Key techniques used in crafting each regex are explained, with links to the corresponding pages in the tutorial where these concepts and techniques are explained in great detail. If you are new to regular expressions, you can take a look at these examples to see what is possible. Regular expressions are very powerful. RegexBuddy offers the fastest way to get up to speed with regular expressions. Oh, and you definitely do not need to be a programmer to take advantage of regular expressions! Grabbing HTML Tags <TAG\b[^>]*>(.*?) <([A-Z][A-Z0-9]*)\b[^>]*>(.*?) Trimming Whitespace You can easily trim unnecessary whitespace from the start and the end of a string or the lines in a text file by doing a regex search-and-replace. More Detailed Examples Numeric Ranges. Matching a Floating Point Number. Matching an Email Address. Matching an IP Address. Matching Valid Dates. Matching Complete Lines.
Popular Tools, Utilities and Programming Languages That Support Regular Expressions These tools and utilities have regular expressions as the core of their functionality. grep - The utility from the UNIX world that first made regular expressions popular PowerGREP - Next generation grep for Microsoft Windows RegexBuddy - Learn, create, understand, test, use and save regular expressions. RegexBuddy makes working with regular expressions easier than ever before. RegexMagic - Generate regular expressions using RegexMagic's powerful patterns instead of the cryptic regular expression syntax. General Applications with Notable Support for Regular Expressions There are a lot of applications these days that support regular expressions in one way or another, enhancing certain part of their functionality. EditPad Lite - Basic text editor that has all the essential features for text editing, including powerful regex-based search and replace. Programming Languages and Libraries If you are a programmer, you can save a lot of coding time by using regular expressions. Databases Make a Donation
Regular Expression Tutorial - Learn How to Use Regular Expressions This tutorial teaches you all you need to know to be able to craft powerful time-saving regular expressions. It starts with the most basic concepts, so that you can follow this tutorial even if you know nothing at all about regular expressions yet. The tutorial doesn't stop there. It also explains how a regular expression engine works on the inside, and alert you at the consequences. This helps you to quickly understand why a particular regex does not do what you initially expected. It will save you lots of guesswork and head scratching when you need to write more complex regexes. What Regular Expressions Are Exactly - Terminology Basically, a regular expression is a pattern describing a certain amount of text. This first example is actually a perfectly valid regex. \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\. With the above regular expression pattern, you can search through a text file to find email addresses, or verify if a given string looks like an email address. Different Regular Expression Engines
Regular Expressions Quick Start This quick start gets you up to speed quickly with regular expressions. Obviously, this brief introduction cannot explain everything there is to know about regular expressions. For detailed information, consult the regular expressions tutorial. Each topic in the quick start corresponds with a topic in the tutorial, so you can easily go back and forth between the two. Many applications and programming languages have their own implementation of regular expressions, often with slight and sometimes with significant differences from other implementations. Text Patterns and Matches A regular expression, or regex for short, is a pattern describing a certain amount of text. Characters with special meanings in regular expressions are highlighted in various different colors. Literal Characters The most basic regular expression consists of a single literal character, such as a. This regex can match the second a too. Learn more about literal characters Character Classes or Character Sets Anchors q(? q(?!