View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.0 | 3 ratings Rate this file 14 Downloads (last 30 days) File Size: 595 KB File ID: #41899 Version: 1.11
image thumbnail




22 May 2013 (Updated )

regexpBuilder is GUI that aims to simplify the creation of regexps in Matlab.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

regexpBuilder() is GUI that aims to simplify the creation of regexps in Matlab. It shows exactly what the various outputs are for the given regexp, text, and input options as you type. All regexp constructs supported by Matlab are allowed, for help on regexps, see doc regexp. A demo is provided, in the help, look under 'Other Demos' -> 'rexpBuilder Demo' -> 'regexpBuilder' -> 'Using the regexpBuilder GUI' in Matlab versions up to R2011b and in 'Supplemental Software' in R2012a and up.
   Enter your regexp in the textbox with "Regexp goes here...".
   Optional inputs to the regexp command are enabled using the
   checkboxes below. An unchecked box signifies the default is used for
   that option. The text to be run on goes in the textbox marked "Text
   to parse goes here".
   If you click the Evaluate button, check one of the option
   checkboxes, or simply type in either the Regexp or Text textboxes,
   the regexp is run against the text and the results are printed in
   the Output panel on the right. Each box corresponds to the
   particular output of the regexp command. For example, the Match
   textbox will contain the same information as [match] =
   regexp(text,regexp,...,'match'), with the addition of the phrase
   'Match #:' signifying which match it corresponds to. You can click
   on the button with the Match label to obtain a bigger window for
   those results.
   If the regexp can match the text, each match is underlined in the
   text and the entire regexp is underlined. If the regexp contains
   tokens (named or unnamed), the definition of each token is
   highlighted in the regexp and every match of the token is
   highlighted in the text with the matching color. Thus, for a regexp
   with many tokens that matches often, your text might look rather
   rainbowy. If you would like to change the color scheme, see the
   highlightText function in this file.
   Lastly, if the you click the Evaluate button, along with the output
   mentioned above, the arguments to the regexp command used are
   printed to the Command Window in the form
       output = regexp(TEXT,REGEXP, ARGUMENTS);


Regexp Helper and Findjobj Find Java Handles Of Matlab Graphic Objects inspired this file.

This file inspired Interactive Regular Expression Maker.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
MATLAB Search Path
Other requirements Note that older versions of Matlab have increasingly fewer capabilities in the regexp command. I've tried to make regexpBuilder version compliant, but I do not have older versions to test. Let me know in the comments if it doesn't work.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
07 Feb 2017 Aditya

Aditya (view profile)

If you do release an update, could you consider renaming the built-in Matlab functions that are being overridden so that it does not cause a name conflict for other tools, especially if this is on the path above the normal Matlab path? Or, you could see if the built-in functions serve the purpose now.

Built-in functions I've found include:

Thank you.

Comment only
09 Aug 2016 Michael Ryan

I do plan on updating, since at a minimum the panel/button arrangement is all messed up in 2016a. I don't have 2015b, and (besides the wonky buttons) it seems to be working in 2016a, so could you provide a bit more information on how it's crashing and what, if any errors are appearing?

Comment only
04 Aug 2016 Brian Wilson

this seems to crash in 2015b. are there plans to upgrade, because i love this tool.

Comment only
24 Mar 2015 Jason Nicholson

Very helpful for building regular expression in MATLAB.

My default prior to using this tool was a regex builder on the web. However, the regex expression that I built was not always compatible with MATLAB. This tool avoids that problem because I am working directly in MATLAB.

05 Jun 2013 Francis B.

After testing on 2013a this is very helpful.

04 Jun 2013 Francis B.

Thanks Mike. I appreciate the help.

Comment only
04 Jun 2013 Michael Ryan

It does matter apparently. R2011a added the ability to perform empty matches, which I didn't realize. I've updated regexpBuilder to be more version compliant. Unfortunately, I do not have access to earlier versions, so I can't test it fully. Let me know if something breaks. Also, your regexp matches the 1GCEC14W9XE186XXX part.

Comment only
04 Jun 2013 Francis B.

Not sure if this matters but I am using Matlab 2010a

Comment only
04 Jun 2013 Francis B.

This is what I steps I have taken:

1. Open regexBuilder.m
2. Click Run function
3. Copy paste the following into 'Regexp goes here...': (?<=content="vin:)(.*?)(?=\")
4. Copy/paste the following into 'Text to parse goes here...': 'meta itemprop="productID" content="vin:1GCEC14W9XE186XXX"/>
<div class="yui3-u" id="nav">&nbsp;</div>
<div class="yui3-u" id="main">
<div class="vDetailTitleWrap clearfix">'
5. Click 'Evaluate'

(Thanks with any/all help)

Comment only
03 Jun 2013 Michael Ryan

I'm updating the description and help text to add a demo. (The update should appear soon.)
Could you explain the process that led to that warning? The error is a direct result of the call to regexp failing and a struct not being populated as a result. I've fixed that in the update, but 'noemptymatch' certainly is a correct (and default) option for regexp, so I'm a bit stumped.

Comment only
01 Jun 2013 Francis B.

Is there any information of a step-by-step process to use this builder? I been using (regexpHelper) and am verify that I have a appropriate search/input information. Any help would be much appreciated. Thanks!

I receive the following Error:

Warning: Invalid option for regexp: noemptymatch.
> In regexpBuilder>doRegexp at 508
In regexpBuilder>evaluate_Callback at 237
In gui_mainfcn at 96
In regexpBuilder at 69
In @(hObject,eventdata)regexpBuilder('evaluate_Callback',hObject,eventdata,guidata(hObject))
??? Reference to non-existent field 'start'.

Error in ==> regexpBuilder>doRegexp at 588

Error in ==> regexpBuilder>evaluate_Callback at 237
regexpCommand = doRegexp(handles);

Error in ==> gui_mainfcn at 96

Error in ==> regexpBuilder at 69
gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)regexpBuilder('evaluate_Callback',hObject,eventdata,guidata(hObject))

??? Error while evaluating uicontrol Callback

Comment only
29 May 2013 Michael Ryan

I have removed the setCaretPosition(caret) aspect. (I was trying to get the text boxes to update correctly as the user typed and was doing it in a very stupid way.) Any action that can be done in a normal text box is now allowed and should be correctly implemented. Let me know if anything else is broken!

Comment only
23 May 2013 Andreas J.

I really like this tool. but what i find rather annoying is the "hObject.setCaretPosition(caret);"

* you can't use CTRL+A
* after typing a character the cursor gets one to the left of the typed character. ~nearly every 2cd character entered the cursor moves left.

24 May 2013 1.1

Greatly improved the as-you-type parsing. I was doing something very stupid (with the setCaretPos stuff). It is now fixed: I no longer use setCaretPos, and Ctrl-A works correctly.

03 Jun 2013 1.2

Updated some error handling with the regexp command. Added demo and updated description and help to reflect that.

05 Jun 2013 1.3

Added version compliance -> No empty match in ver<R2011a, no split in ver<R2007b, no ignore case, multiline, or freespacing in v<R2006a.

30 Jul 2013 1.4

Revised and added additional print command options. Now only prints the non-default options, unless specified otherwise, along with only the selected outputs. Updated help.

19 Aug 2013 1.5

Fixed bug introduced in previous version with dot matches newline option. Now changed to dot except newline.

16 Oct 2013 1.9

Updated to include the suggestions from the POTW article: Results boxes are no longer editable, added text import from files and URLs, UI placement tweaks.

23 Mar 2015 1.10

The R2014b graphics update introduced a few bugs. I've included the latest(3/23/2015) version of Yair Altman's findjobj.m as well as done some reordering of the ui components. Let me know if there are any further issues.

01 Jul 2015 1.11

Reduced startup time, improved visuals by using JIDE components. (Thanks!). Issue with resizing figure window, so that is currently disabled. Also, this has been tested on 2015a. Let me know about issues.

Contact us