File Exchange Pick of the Week

Our best user submissions

Regexp Builder

Idin's pick for this week is theregexpBuilderbyMichael Ryan.

Regular expressionscan be a powerful tool in searching through strings or documents. If you haven't used them before, think of them as a string pattern matching tool on steroids.

MATLAB introduced support for regular expressions in MATLAB 6.5 (R13). You can read about regular expressions in MATLAB这里. There are also a couple of blog posts on Loren Shure's Art of MATLAB这里这里.

Despite their usefulness, the drawback to regular expressions has always been their non-intuitive syntax. For example, how do you find all strings that start with a capital "B" and end with "e"? Here is one option:

regexp('Bobbie was born on Bastille Day before dawn.','B[a-z]*e')

现在,如果我想忽略案件怎么办?还是允许字符串中的空间?正则表达式可以处理所有这些情况,但是需要一些经验,有些则需要。

Michael's regexpBuilder is an app that allows the user to interactively build their regular expression and see the results in real time. It even has checkboxes for some of the more common tasks (e.g. "ignore case", or "match once"). This can help reduce the time (and frustration) needed to construct the desired regular expression.

用户界面非常简单:在大“文本”框中输入到文本搜索,然后开始在左上角的“ Regexp”框中输入正则表达式。该工具通过突出显示和/或强调文本窗口中的匹配项来显示结果,但也进一步:它列出了屏幕右侧MATLAB的RegexP功能的所有不同输出。为了使事情变得更加方便,当您按“评估”按钮时,它还在MATLAB命令提示符上回荡了等效的MATLAB命令。

Suggestions for improvements

该应用程序可以很好地完成其广告任务。以下是有关可以添加的内容的一些想法:

  • The user interface could be cleaned up to look more professional
  • 右侧的文本框不应该由用户使用,并且可能应该锁定,以便用户不在其中输入。
  • Ability to import text files and/or web page would be nice.

As always, your thoughts and comments这里are greatly appreciated.




Published with MATLAB® R2013b

|
  • print
  • send email

注释

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.