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. Note: regexpBuilder has been rebuilt from the ground up to work with R2020a and later!
Enter your regexp in the textbox with "Regexp goes here...".
Optional inputs to the regexp command are enabled using the toggle buttons; an unset button gives the default value for the option.
Add the text to be regex'd to the "Text to parse goes here..." box. (a preview of found matches will appear in the adjacent box.)
Press the evaluate button to see a preview of any matches below, as well as the values of the various possible outputs, on the left. (Bigger output windows can be obtained by clicking the corresponding button).
Imports and Exports There are 3 ways to import text into regexpBuilder:
Using the optional inputtxt parameter will prepopulate the input text box on startup.
Using the Import from URL button on the Import tab will pop up a window prompting a URL to import from. regexpBuilder uses webread to open URLs.
Using the Import from file will open a File Chooser dialog, select the file to import there. regexpBuilder uses fileread to open files.
The Export tab provides a way to export the final regexp command, as well as a variety of options for the export, generally corresponding to the output options for regexp. Note that only non-default options will be written to the command line.
If the regexp can match the text, each match is underlined in the right text box. If the regexp contains tokens (named or unnamed), every match of the token is highlighted in the text with the color corresponding to the token. Thus, for a regexp with many tokens that matches often, your text might look rather rainbowy. regexpBuilder uses the jet colorscheme, so you can change the colorscheme by shadowing the jet colormap.
I've only been able to test this on one machine/MATLAB version so far, so please let me know about any bugs in the comments!
Michael Ryan (2022). regexpBuilder (https://www.mathworks.com/matlabcentral/fileexchange/41899-regexpbuilder), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!