Graphrex is a plugin that adds Java regular expression visualization to your Eclipse installation:

Graphrex screenshot with 5 labels
(click on the diagram to zoom)
  1. A new .graphrex resource type with its own editor: the Graphrex editor.
  2. A new view, the Regex view, that shows the text of your regular expression. When this text is edited the editor is updated with a new diagram as soon as you click outside the view.
  3. The Graphrex editor page shows the graphical representation of your regular expression.
  4. Graphrex adds some controls to Eclipse’s action bar. There are controls to zoom the view (Ctrl-+ and Ctrl– also work), to neatly arrange the diagram if you drag or resize the components, and a fit to page button.
  5. Finally, the outline view shows the structure of your regular expression in a tree format (there’s also a graphical outline). Selecting an item in the tree also selects the corresponding node in the diagram (and vice versa), making it easy to see what’s what.

A Graphrex walk-through

Let’s take a quick tour through Graphrex’s features. First, download and install Graphrex in your copy of Eclipse.

Creating a new diagram file

After installing Graphrex in Eclipse, open an empty diagram. Select File > New > Other … then type Graphrex in the filter text field. If you successfully installed Graphrex you will see Graphrex Diagram as one of the choices in the Other folder. Select it and click Next to choose a filename (the extension must be .graphrex) in the usual way.

Empty Graphrex diagram
An empty Graphrex diagram.

You’ll see an empty diagram in the Graphrex editor window. The Regex view will also open automatically, but it will be empty. The empty diagram is what you will see when the Regex view is empty or contains an invalid regex that Java can’t parse. For more about the latter situation, see below.

Entering a regular expression.

Screenshot of regex and diagram for a|b
Creating the diagram for a|b.

The time has come to enter a regular expression. Click in the regular expression editor in the Regex view and enter a regular expression, for example a|b, then click somewhere outside the Regex view, or on the update button (the lightning flash) in the action bar of the view. The Graphrex editor immediately updates with the new diagram and you can save it by Ctrl+s in the usual way. The diagram and your regex are stored in the .graphrex file. It’s an XML file (actually an EMF file) so you can look at it with the text editor if you want to.

Error conditions

What happens if things go wrong?

The regular expression editor in the Regex view shows an error marker if the Java regex parser finds a syntax error. Hovering on the marker returns the error message that the parser provides. Hopefully this helps you to fix the problem.

An error condition caused by an invalid regular expression
Error markers

But if you click outside the Regex view the Graphrex editor is going to try to update its diagram. Since Graphrex can’t create a diagram from an invalid expression it will display an empty diagram with an error marker, as shown here.

If you hit save at this point your regex will be stored, so you will return to this situation if you close and re-open the diagram. So if you get an error you can come back and work on it later.

Arranging the diagram

When Graphrex first creates a diagram it tries to arrange it neatly, but you may need to re-do the arrangement if you open one of the drop-down boxes or change the diagram by dragging nodes around.

Shows the "arrange all" button
The “arrange all” button (arrowed).

To re-arrange the diagram you use the arrange all button that Graphrex adds to Eclipse’s action bar. It is also available on the Graphrex menu and the diagram’s context menu.

Outputting a diagram

As the last steps in our walk-through, let’s look at how to print a diagram and how to output it as an image file.

As you might expect, you print a diagram by selecting File > Print. You may find that it helps to use your printer properties to set landscape mode.

You can output a diagram as an image file by using File > Export. Find the Graphrex diagram choice under Other, and click through the wizard to select the diagram (i.e. the .graphrex file) that you want to export. On the next wizard page choose the filename and the image type, then Finish.


We hope that you find Graphrex useful and that you enjoy using it. We’re going to be enhancing it quite a bit, so please give us feedback in our forum and let us know what bugs you find and what enhancements you would like to see. We’ll do our best to fix the former and develop the latter.