加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Notepad++列编辑、正则查找、替换

发布时间:2020-12-14 01:25:01 所属栏目:百科 来源:网络整理
导读:本文 转载自 : 高爽|Coder ,原文地址: http://www.jb51.cc/article/p-bubponua-kw.html 。 目标 : 将源数据转成初始化sql语句。 源数据 : [plain] view plain copy print ? 104110040018,1,中国银行,中国银行天津琼州道支行,NULL,1100,天津市,12,天津市


本文转载自高爽|Coder,原文地址:http://www.52php.cn/article/p-bubponua-kw.html

目标

将源数据转成初始化sql语句。
源数据

[plain] view plain copy print ?
  1. 104110040018,1,中国银行,中国银行天津琼州道支行,NULL,1100,天津市,12,天津市
  2. 104110040059,中国银行天津利民道支行,天津市
  3. 104110040091,中国银行天津九龙路支行,天津市
  4. 104110040106,中国银行天津枫林路支行,226)"> 104110040139,中国银行天津滨湖路支行,226)"> 104110040155,中国银行天津南楼支行,226)"> 104110045006,中国银行天津和平支行,226)"> 104110050021,中国银行天津海洋支行,226)"> 104110050048,中国银行泰达大街支行,天津市

处理列头

将光标定位在第一行数据开始处,按alt+c组合键,弹出列编辑窗口,如图:

插入相应文本,确定后,数据变成了下面这样:

    insertintot_bankvalues(104110040018,226)"> insertintot_bankvalues(104110040059,226)"> insertintot_bankvalues(104110040091,226)"> insertintot_bankvalues(104110040106,226)"> insertintot_bankvalues(104110040139,226)"> insertintot_bankvalues(104110040155,226)"> insertintot_bankvalues(104110045006,226)"> insertintot_bankvalues(104110050021,226)"> insertintot_bankvalues(104110050048,85); font-family:'microsoft yahei'; font-size:15px; line-height:35px"> 处理列尾

    按ctrl+h组合键,弹出替换窗口,如图:

    windows下,每行都以这两个字符结束,r使光标移到行首,n使光标下移一行,注意要将查找模式选择为扩展,全部替换后,数据变成了下面这样:

    处理文本

    要将中文转换成两端带单引号的,匹配中文需要用正则[一-龥]+,这里的问题是我们替换的时候要获取当前匹配的字符串,按ctrl+h组合键,弹出替换窗口,如图:

    使用小括号将匹配的字符串包上,然后替换值中可以通过$1表达式来获取到当前正在匹配的值,这里可以更复杂些,比如存在多个小括号,相应的可以使用$1、$2、$3来获取对应值,全部替换后,就是我们最终想要的数据了。

    [sql]
      insertintot_bankvalues(104110040018,'中国银行','中国银行天津琼州道支行',NULL,'天津市','天津市');
    1. insertintot_bankvalues(104110040059,'中国银行天津利民道支行','天津市');
    2. insertintot_bankvalues(104110040091,'中国银行天津九龙路支行',226)"> insertintot_bankvalues(104110040106,'中国银行天津枫林路支行',226)"> insertintot_bankvalues(104110040139,'中国银行天津滨湖路支行',226)"> insertintot_bankvalues(104110040155,'中国银行天津南楼支行',226)"> insertintot_bankvalues(104110045006,'中国银行天津和平支行',226)"> insertintot_bankvalues(104110050021,'中国银行天津海洋支行','天津市');

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读