Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79801
  • 博文数量: 18
  • 博客积分: 840
  • 博客等级: 准尉
  • 技术积分: 150
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-20 11:51
文章分类
文章存档

2010年(5)

2009年(1)

2008年(12)

我的朋友

分类: C/C++

2010-07-15 22:41:20

今天搞了一下Source Insight,好久没在家里用了,今天配置了一下编译器,安装了MINGW,以后在家写东西就用这个了,我用的版本是mingw32-gcc-3.4.5 + source insight 3.5
 
找了个正则表达式,用来解析编译结果:^\([a-zA-Z].*\):\([0-9][0-9]*\)
 
稍微解释一下:
^\([a-zA-Z].*\):\([0-9][0-9]*\)
//这个表达式就是搜索是否存在类似  xxxx:12 这样的组合
 
gcc编译结果类似于:
F:\prj\DataStructLib\list\v_list.h:23: error: syntax error before "ulPrio"
 
 
Source insight规定Regular Expression Groups是\( and \)之间的表达式,详细的说明如下:
 
Regular Expression Groups

\( and \)

Parts of a regular expression can be isolated by enclosing them with \( and \), thereby forming a group. Groups are useful for extracting part of a match to be used in a replacement pattern. Each group in a pattern is assigned a number, starting with 1, from left to right.

Example: abc\(xyz\) matches abcxyz. xyz is considered group #1.

This is not all that useful, unless we are using the Replace command. The replace string can contain group characters in the form of \. Each time a group character is encountered in the replacement pattern, it means “substitute the group value from the matched pattern”.

Example 1: replace \(abc\)\(xyz\) with \2\1. This replaces the matched string abcxyz with the contents of group #2 xyz, followed by the contents of group #1 abc. So abcxyz is replaced with xyzabc. This is still not too amazing. See the next example.

Example 2: replace \(\w+\)\(.*\)ing with \1\2ed. This changes words ending in ing with the same word ending with ed. Your English teacher would not be too happy.

阅读(374) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~