Interactive Regular Expression Tool

버전 4.0.2 (157 KB) 작성자: Stephen23
Develop and refine regular expressions in an interactive figure that shows all of REGEXP's outputs.
다운로드 수: 1.8K
업데이트 날짜: 2024/9/8

라이선스 보기

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 :)

인용 양식

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

MATLAB 릴리스 호환 정보
개발 환경: R2010b
R2023b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
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