vi 中的正则表达式[x-y] | 匹配以字符范围组成的组中的一个字符 | /[A-Z]ove | 匹配所有这样的行, 这些行包含如下字符 | | |第一个字符是从A到Z 中间的一个, 后面跟 | | |着ove ----------------------------------------------------------------------------------------------- [^] | 匹配一个不在范围内的字符 | /[^A-Z]ove/ | 匹配所有这样的行, 这些行包含如下字符 | | |第一个字符不是从A到Z 中间的一个, 后面 | | |跟着ove ----------------------------------------------------------------------------------------------- \ | 用来转义一个字符 | /love\./ | 匹配所有这样的行, 这些行包含如下字符 | | |love 后面跟着一个点, 通常点是表示任何 | | |字符的通配符. ----------------------------------------------------------------------------------------------- \< | 锚定单词的开始 | /\<love/ | 匹配所有这样的行, 这些行包含以love | | |开头的单词 (vi & grep 都支持这个功能) ----------------------------------------------------------------------------------------------- \> | 锚定单词的结束 | /<love\> | ... ^ ... 以love结束的单词 ... ^ ----------------------------------------------------------------------------------------------- \(..\) | 标记后面用到的匹配字符 | /\(love\)a\1b | 最多可以使用9个标签. 第一个标签是模板 | | |最左边的部分. 在这例子中, 模板love | | |保存为标签1, 后面的\1指的就是love; | | |本例子搜索的是这样的行, 这些行包含这样 | | |的字符,在lovea 后面跟着loveb. ------------------------------------------------------------------------------------------------ [NOTE: 各种版本的Unix 以及模板匹配 (pattern-matching) 实用程序并不都是可信赖的, 通常我们使用 vi & grep] 假设你熟悉 vi 是如何工作的, 每一个元字符都在 vi 搜索字符串的术语中有详细描述. 下面的例子中, 被加重的字符就是 vi 将找到的匹配字符. 文本如下: I had a lovely time on our little picnic. Lovers were all around us. It is springtime. Oh Love, how much I adore you. Do you know the extent of my love? Oh, by the way, I think I lost my gloves somewhere out in that field of clover. Did you see them? I can only hope love is forever. I live for you. It's hard to get back in the groove. ~ ~ ~ /love/ 结果如下: I had a lovely time on our little picnic. ^ Lovers were all around us. It is springtime. Oh ^ Love, how much I adore you. Do you know ^ the extent of my love? Oh, by the way, I think ^ I lost my gloves somewhere out in that field of ^ clover. Did you see them? I can only hope love ^ ^ is forever. I live for you. It's hard to get back in the groove. // 还有一些测试命令如下: /^love/ /love$/ /l.ve/ /[lL]ove/ /ove[a-z]/ /ove[^a-zA-Z0-9]/ // //:~ Tue 22 Apr 2003 11:42:51 PM CST //:~ End Of PAGE 1 原文链接:http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=19714 更多相关文章
|
推荐文章
精彩文章
|