最近使用vim的正则替换功能,非常强大一个文件:1,2,34,5,61,2,34,5,61,2,34,5,61,2,34,5,61,2,34,5,6现在需要删除逗号前面的内容,那么在vim敲入命令::%s/.*,//g得到的结果是: 3 6 3 6 3 6 3 6 3 ...
分类:
系统相关 时间:
2015-05-07 11:53:18
阅读次数:
138
editplus查找替换的正则表达式应用表达式 说明\t 制表符.\n 新行.. 匹配任意字符.| 匹配表达式左边和右边的字符. 例如, "ab|bc" 匹配 "ab" 或者 "bc".[] 匹配列表之中的任何单个字符. 例如, "[ab]" 匹配 "a" 或者 "b". "[0-9]" 匹配任意数...
分类:
其他好文 时间:
2015-04-23 12:45:13
阅读次数:
173
(?)(\s+)(?=)(\s+)(?)(?=与<中间插入一个换行符。MyEclipse 10 的XML格式化好像不太满意,就简单实现了一个这个,而且MyEclipse 没有找到比较快的正则替换方法,就用的Notepad ++。。由于能力限制,这个方法有点麻烦且没有缩进。
分类:
其他好文 时间:
2015-03-31 08:55:44
阅读次数:
134
在PHP应用中,正则表达式主要用于:正则匹配:根据正则表达式匹配相应的内容正则替换:根据正则表达式匹配内容并替换正则分割:根据正则表达式分割字符串在PHP中有两类正则表达式函数,一类是Perl兼容正则表达式函数,一类是POSIX扩展正则表达式函数。二者差别不大,而且推荐使..
分类:
Web程序 时间:
2015-03-19 18:36:34
阅读次数:
158
$string=‘April15,2003‘;$pattern=‘/(\w+)(\d+),(\d+)/i‘;$replacement=‘${1}1,\3‘;//$replacement=‘${1}1,$3‘;//$replacement=‘${1}1,{3}‘;echopreg_replace($pattern,$replacement,$string);echo‘<br/>‘;//-----------------------------$string=‘Thequickbrownfoxjump..
分类:
Web程序 时间:
2015-03-19 16:35:57
阅读次数:
183
Change this way :param => ‘value‘ for this way param: ‘value‘ open .rb file in vim and do %s/:\([^=,‘"]*\) =>/\1:/g if you want use the interactive mode, add c in the end of command %s/:\([^=,‘"]*\...
分类:
系统相关 时间:
2015-02-13 08:10:57
阅读次数:
178
var reg = "/[//]" + str + "/g";//创建正则字符串 特殊字符需要用[]转义
var myregex = eval(reg);//转换为正则对象
var content = $("#txtContent").html().replace(myregex, "");//批量替换...
分类:
Web程序 时间:
2015-02-08 11:39:21
阅读次数:
198
版本一:#coding:utf-8import re#把文档中的单引号替换为2个单引号def replacestr(matched): matchedstr = matched.group() x = matchedstr.replace("'", "''") return xdef main():...
分类:
数据库 时间:
2015-02-06 18:25:42
阅读次数:
157
js方法: var urlqr = location.href; urlqr = urlqr.replace(/iphoneF_/, "pc")这里写正则替换页面地址if(IsPC()) window.location.replace(urlqr);//PC端访问就跳转到PC页面else windo...
分类:
移动开发 时间:
2015-02-06 18:10:50
阅读次数:
199
替换文件中字符(正则) #!/usr/bin/env python import re filename = 'source.c' text = open(filename).read() r = re.compile(r'/\*.*?\*/', re.DOTALL) cr= re.compile(...
分类:
其他好文 时间:
2015-02-06 16:30:25
阅读次数:
134