当前位置: 首页 > news >正文

介绍一款开源的正则表达式测试工具-Regex Tester

原文来自:  YART - Yet Another Regex Tester

I know, I know, there are soooo many regular expression tester tools available on the 'Net, but I couldn't help creating my own. It's very simple, yet it supports all the basic features you'd espect from a tool of its kind, including code generation (VB and C#) and compilation to stand-alone assemblies. Best of all, it comes with source code. You can download it from the home page of my Visual Basic 2005 book (together with all other code samples in the book) or directly from here:

Executable (requires .NET Framework 2.0): RegexTester.zip (75.57 KB)
Source code (VB2005): RegexTester source.zip (88.15 KB)

Using the tool is quite simple. The main window is divided in three panes: (a) the pane where you enter the regex, (b) the pane where you load the text the regex must be applied to, (c) the result pane. A fourth pane appears when you select the Replace item from the Commands menu, and it's where you enter the replace pattern. As you can see in the image below, you can enter most regex patterns by selecting them from the context menu:

You select the kind of command (Find, replace, Split) from the Commands menu and you select one or more regex options from the Options menu:

After selecting the proper options, you press the F5 key (the Run item in the Commands menu) to execute the regex. Results are displayed in the bottom pane in a variety of formats and sort orders, which you can select from the Results menu, and the status bar displays the number of matches, the execution time, and the properties of the result currently highlighted in the result pane:

Alternatively, you can set all these options from the Properties dialog box (the Properties command in the File menu, or just press the F4 key):

Assigning a name to the current regex is important because you can save it on disk in a file with .regex extension, for later retrieval.

The Commands menu contains a couple of other interesting items. First, you can generate the C# or VB code for the current regular expression and copy it to the Clipboard:

Second, and more interesting, you can compile one or more regular expressions (including saved .regex projects) into a compiled assembly, which you can later reference from any .NET application. Using such compiled regexes is obviously faster than defining them in code, because you skip the parsing step:

 

That's it. You can use the YART tool for your own use, study its source code, modify and expands it as you like. If you find any major problems or add some noteworthy feature, just let me know.


 如果你不觉得正则表达式很难读写的话,要么你是一个天才,要么,你不是地球人。正则表达式的语法很令人头疼,即使对经常使用它的人来说也是如此。由于难于读写,容易出错,所以找一种工具对正则表达式进行测试是很有必要的。

由于在不同的环境下正则表达式的一些细节是不相同的,本教程介绍的是微软 .Net Framework 2.0下正则表达式的行为,所以,我向你介绍一个.Net下的工具Regex Tester。首先你确保已经安装了.Net Framework 2.0,然后下载Regex Tester。这是个绿色软件,下载完后打开压缩包,直接运行RegexTester.exe就可以了。
下面是Regex Tester运行时的截图


 

 

再介绍几个平时收藏的关于正则表达式的网站,通俗易懂的:

正则表达式30分钟入门教程
(在介绍中国固定电话号码的时候有点没有说清楚,国内有3位区号+7位号码的和2位区号+8位号码的)
正确的写法应该是:^\(0\d{2}\)\d{8}$|^0\d{2}-\d{8}$|^\(0\d{3}\)\d{7}$|^0\d{3}-\d{7}$
这样就不会出现"(021-6666888"或者"(0816-6668888"的出现了。

 


微软的关于正则的说明 


转载于:https://www.cnblogs.com/maqintoshi/archive/2009/01/15/regex_tester.html

相关文章:

  • Asp.Net中CS中获取物理路径
  • npm 安装
  • Delphi 与 DirectX 之 DelphiX(50): TDIB.DoLightness();
  • 小型企业局域网免费上网行为管理方案
  • docker~Dockerfile方式建立镜像HelloWorld
  • jQuery for Asp.Net 一步一步从入门到精通(附 jQuery API 彩色大图)
  • 最新如何解决git 输入github时每次都要输入用户名和密码问题
  • Output Designer 标尺设置
  • 数据库基础知识_
  • POJ 2753 菲波那契数列 解题报告
  • 接口测试实践
  • 用网站地图帮助搜索引擎
  • svn path already exists的解决办法
  • 千里奔丧
  • 浅谈性能测试
  • 《Java编程思想》读书笔记-对象导论
  • Angular Elements 及其运作原理
  • angular2 简述
  • Flannel解读
  • Java编程基础24——递归练习
  • node-glob通配符
  • Object.assign方法不能实现深复制
  • Terraform入门 - 3. 变更基础设施
  • vagrant 添加本地 box 安装 laravel homestead
  • Vue 重置组件到初始状态
  • Vue2.x学习三:事件处理生命周期钩子
  • 聚类分析——Kmeans
  • 融云开发漫谈:你是否了解Go语言并发编程的第一要义?
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 网络应用优化——时延与带宽
  • 微信小程序:实现悬浮返回和分享按钮
  • 终端用户监控:真实用户监控还是模拟监控?
  • 组复制官方翻译九、Group Replication Technical Details
  • ​secrets --- 生成管理密码的安全随机数​
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • #、%和$符号在OGNL表达式中经常出现
  • #if 1...#endif
  • #NOIP 2014# day.2 T2 寻找道路
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • ${factoryList }后面有空格不影响
  • $con= MySQL有关填空题_2015年计算机二级考试《MySQL》提高练习题(10)
  • (NO.00004)iOS实现打砖块游戏(十二):伸缩自如,我是如意金箍棒(上)!
  • (Redis使用系列) Springboot 实现Redis消息的订阅与分布 四
  • (Ruby)Ubuntu12.04安装Rails环境
  • (二十一)devops持续集成开发——使用jenkins的Docker Pipeline插件完成docker项目的pipeline流水线发布
  • (分享)一个图片添加水印的小demo的页面,可自定义样式
  • (附源码)php新闻发布平台 毕业设计 141646
  • (更新)A股上市公司华证ESG评级得分稳健性校验ESG得分年均值中位数(2009-2023年.12)
  • (未解决)macOS matplotlib 中文是方框
  • (五)Python 垃圾回收机制
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (转)c++ std::pair 与 std::make
  • (转)h264中avc和flv数据的解析
  • **CI中自动类加载的用法总结
  • .bat批处理(十一):替换字符串中包含百分号%的子串