Export The Analysis of a Regular ExpressionThe regex tree RegexBuddy shows on the Create panel is perfect for explaining to others how a regular expression works. You can include the regex tree in your documentation or teaching materials by clicking the Export button. This pops up a window that lets you choose how and what to export.

A plain text export generates a plain text file that can be opened in any text editor. You should specify a file name with a .txt extension. The caption is placed at the top of the text file. You can export both the regular expression tree and the replacement text tree into the same file. Each node in the tree will occupy one line in the text file, indented with spaces. When viewing the text file in a text editor, turn off word wrap to clearly see the tree structure. The part of the regex that each node refers to is repeated at the end of the node, quoted between guillemets. Plain text files cannot include links.
A Markdown export generates a plain text file with Markdown formatting. The caption is placed at the top of the file as a level 1 header. You can export both the regular expression tree and the replacement text tree into the same Markdown file. The regex will be indented as a code block. The regex tree will be formatted as a Markdown list, using nested lists for indentation. The part of the regex that each node refers to is repeated at the end of the node as inline code.
You can choose whether you want the Markdown file to link to www.regular-expressions.info or not. If you do then each regex tree item then becomes a link that references a number. The actual URLs are listed with their numbers at the bottom of the Markdown file.
A web page export generates an HTML file. The caption is used for the title and header tags in the HTML file. The regular expression or replacement text is shown with the same syntax coloring as in RegexBuddy. The page’s background color will be the same as that of RegexBuddy’s editor controls, to make sure the syntax coloring is properly legible. If you want different colors for your HTML export then open the Preferences dialog before exporting the regex tree. On the Editors page in the Preferences dialog, click the Regex button. Select the color palette you want to export with. After exporting you can change it back to what you want RegexBuddy to use. You can select a light palette while using a dark theme or vice versa. The HTML export uses only the regex color palette, not the full UI theme.
The HTML file uses separate DIV tags for the regular expression and the regular expression tree. The tree is formatted as a bulleted list, with nested lists for indentation. If the tree is too long to fit within the browser’s height then only the tree gets a scroll bar. Moving the mouse pointer over the regular expression or the regex tree highlights the corresponding parts in the regular expression and in the regex tree. This way, you can always easily follow where you are in the regular expression and in the regex tree at the same time. The downside is that you cannot export both the regex tree and the replacement tree into the same HTML file. If you want to export both then you’ll need to export 2 HTML files.
You can also choose whether you want the HTML file to link to www.regular-expressions.info or not. If you do then each node in the regex tree will link to the page in the tutorial on this web site that explains the node. If you plan to upload the HTML file to your web site then you should definitely include the links. This makes it much easier for your site’s visitors to learn more about regular expressions. The tutorial at www.regular-expressions.info is the same tutorial as the one in RegexBuddy’s documentation.
When you view the HTML file exported by RegexBuddy, you will see the regular expression at the top of the page, and the regex tree as a bulleted list below it. This makes it very convenient to grasp which part of the regex does what, just like clicking on regex tree nodes does on the Create panel in RegexBuddy.
To enable the syntax coloring and the highlighting of corresponding parts in the regex and the tree, the HTML file uses some CSS and JavaScript. By default, the CSS and JavaScript are embedded into the HTML file, so you have only one file to deal with. But if you want to export many regexes and/or replacement texts to HTML, then you may consider using separate CSS and JavaScript files. You can specify the full path to CSS and/or JS files on your computer. RegexBuddy will create the files. RegexBuddy will not overwrite the files if they exist. The CSS and JS are the same for every regex or replacement that you export using the same color palette. So you only need to export those once. If you want to change the palette then you need to delete the CSS and JavaScript files before exporting again. If you’ve already uploaded the CSS and/or JavaScript files to a web server then you can specify a URL to those files instead. The HTML file then references those URLs to load the CSS and JavaScript that it needs. RegexBuddy does not check whether the URLs are actually valid and does not upload anything. This gives you the flexibility to reference your website’s own CSS and JavaScript files to which you added the CSS and JavaScript that RegexBuddy’s HTML export needs.
An image export creates an image file that shows all the nodes in the regex tree or the replacement text tree. If you want to export both then you need to export two images. You should specify a file name with a .png or a .bmp extension. The .bmp extension selects the Windows Bitmap file format. Any other extension selects the PNG file format. The image will be large enough to show the full tree without needing to wrap the text of any nodes. The nodes will also show the same icons as they do on the Create panel in RegexBuddy.
The regular expression or replacement text itself are not added to the image. So to form complete documentation, you would add the image to a document in a word processor and copy the regex or replacement from RegexBuddy and paste it into the word processor. If you copy part or all of a regex or replacement in RegexBuddy using Ctrl+C then it makes the copied text available on the clipboard in 3 formats: plain text, RTF, and HTML. The latter two use syntax coloring. You can use the “paste special” or similar command in your word processor to paste the format that gives the best results. When pasting in Microsoft Word, for example, pasting the HTML produces a more accurate result than pasting RTF.
There is a Copy button immediately to the right of the Export button on the Create toolbar. This shows a reduced version of the Export dialog. It omits the HTML format and the CSS and JavaScript settings exclusive to that format. For the other formats, the Copy command produces the same output as the Export command. The only difference is that the output is placed on the clipboard instead of written to file.
If you plan to include the regex tree as documentation in software source code then you can generate a comment with the regex tree on the Use panel instead of exporting it on the Create panel. The Use panel will generate a source code snippet that you can paste into your source code directly. All source code templates included with RegexBuddy have “functions” that generate a comment or a string with RegexBuddy’s regex or replacement tree. This is basically the export in plain text format but formatted according to the rules for comments or string literals of the programming language you’re working with.