When you need to edit a regular expression written by somebody else, or if you are just curious to understand or study a regex you encountered, copy and paste it into RegexBuddy. If the regex is used as part of an application’s source code, just copy the entire string or regex operator, and let RegexBuddy extract the regex from the string. When working with Java code, for example, copy the Java string containing the regex and select “Paste as Java string” in RegexBuddy. RegexBuddy then properly removes the quotes and escape characters.
As soon as you paste in the regex, RegexBuddy’s regex tree gives you a clear analysis of the regular expression. Click on the regular expression, or on the regex tree, to highlight corresponding parts. Collapse part of the tree to get a good overview of complex regular expressions. If you are new to regular expressions, this is an excellent way to learn by example.
RegexBuddy’s analysis is not some generic description of the regex syntax. It explains exactly how your chosen application interprets each part of the regular expression. In the screen shot, \d is explained as “Match a single character that is a digit (ASCII 0–9 only)” because that’s what Java does. If the application were changed to C#, this would change to “Match a single character that is a digit (0–9 in any Unicode script)”. While any regex tester can show you which of your samples the regex matches and doesn’t match, only RegexBuddy can accurately tell you what to expect. RegexBuddy’s regex tree enables white-box testing. Without it you might not have thought of testing a regex that contains \d on text with non-ASCII digits, only to get bug reports later when your software is exported around the world.
When the brief descriptions of the regex tree are not clear enough, just click the Explain Token button to access RegexBuddy’s detailed regular expression tutorial. It will open at the page that explains the item selected in the regex tree.
You can export the regex tree to an HTML file to document the regular expression outside of RegexBuddy. Moving the mouse over the tree highlights corresponding parts, as you can see below.
<B[^>]*>(.*?)</B>
Of course, the only way to be 100% sure if a regex matches a particular piece of text is to try it and find out. Just click on the Test tab, click the Highlight button, and type in the text or open the file you want to test the regex against. You will see right away what matches, and what does not.
Once you understand the pattern, store the regular expression into a RegexBuddy library for later reuse. Or, edit the regex and replace the original.
RegexBuddy takes the mystery out of regular expressions. Never again encounter a regex that you can’t comprehend. Get your own copy now!