Interactive Regular Expression Tool

Versión 4.0.2 (157 KB) por Stephen23
Develop and refine regular expressions in an interactive figure that shows all of REGEXP's outputs.
1,8K Descargas
Actualizado 8 sep 2024

Ver licencia

Finally, new features of UIFIGURE allowed me to write the GUI that I wanted to write 10 years ago...
IREGEXP is a simple interactive tool to help develop regular expressions. IREGEXP lets you interactively write regular expressions and see REGEXP's outputs update as you type.
IREGEXP consists of just one M-file which creates a figure containing two edit-boxes (for the input text and a regular expression) and that displays all of REGEXP's outputs inside the figure.
IREGEXP can be used in two ways (and in any combination of these two ways):
  1. interactively by typing directly into the figure's edit-boxes, or
  2. by calling the function with exactly the same inputs and options as REGEXP itself.
Simply keep the figure open to use any combination of these two modes of operation: this allows for refining of the regular expression by changing the parse and regular expression strings, and also updating any REGEXP options that are supplied as function inputs. Text can be copied and pasted both to and from the two edit-boxes. If required, REGEXP's output values can be returned by calling the function with the appropriate output specifiers (by default there are no function outputs).
Keep It Simple
IREGEXP is intended to be the simplest interactive regular expression tool on FEX: no highlighting, no links, no colors, no buttons, no java code, no file parsing, no apps to install, no third-party dependencies... just this one M-file is all you need. IREGEXP aids fast development of a regular expression, especially by allowing editing using only the keyboard (use the TAB key to switch between the edit-boxes), to parse short pieces of text.
Example
Ellipses indicate continuation without closing the figure window.
% Call with the default parse and regular expression strings:
>> iregexp()
% ...interactively add the parse string '0_AAA111-BB22.CCCC3'.
% ...interactively add the regular expression '([A-Z]+)'.
% ...call to set a new parse string:
>> iregexp('0_aaa111-BB22.cccc3',[])
% ...interactively change the regular expression to '([a-z]+)\d+'.
% ...call to allow case-insensitive matching:
>> iregexp([],[],'ignorecase')
% ...interactively change the regular expression to '(?<str>[A-Z]+)(?<num>\d+)'.
% ...call to assign selected outputs to some variables:
>> [A,B,C,D] = iregexp([],[],'ignorecase','match','start','tokens','split')
A = {'aaa111', 'BB22', 'cccc3'}
B = [3, 10, 15]
C = {{'aaa','111'},{'BB','22'},{'cccc','3'}}
D = {'0_','-','.',''}
MATLAB <R2023b
Click on the "Version History" tab and download version 3.1.1. It does not have all the nice features of UIFIGURE, but works as documented :)

Citar como

Stephen23 (2024). Interactive Regular Expression Tool (https://www.mathworks.com/matlabcentral/fileexchange/48930-interactive-regular-expression-tool), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2010b
Compatible con cualquier versión desde R2023b
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre String Parsing en Help Center y MATLAB Answers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
4.0.2

* Add Placeholder text (for empty text fields).
* Code tweaks.

4.0.1

* Change default space character representation
* Added examples to HTML documentation

4.0.0

* Total rewrite using UIFIGURE and UIGRIDLAYOUT
* Text fields using UITEXTAREA and UIEDITFIELD
* Text callbacks using VALUECHANGEDFCN (i.e. no more dodgy keypress hack!)

3.1.1

* Fix bug in token display with 'once' option.
* Improve documentation.

3.1.0

* Display string outputs with "".
* Return string outputs as string.
* Add HTML examples.

3.0.0

* Allow string class input arguments.
* Improve pretty-print local functions.

2.1.1

* Added fix suggested by Zhuohe Liu.

2.1.0

* Simplify code with UITABLE (replacing multiple UICONTROL text boxes).

2.0.0.0

* rename function.
* try to make HG2 compatible (needs testing).
* simplify internal handling of output arguments.

1.1.0.0

* Display outputs in edit boxes (as these have scrollbars).
* Input string can change ParseString edit box to multi-line.

1.0.0.0