有这样一个需求,就是一个文本中,需要找出指定格式的字符串进行指定的替换,当前我的真实需求是,一个sql创建触发器的文本,我需要将所有的 包含 TB_SYS 的表名后面添加一个 “_NEW”字符串!
例如:
Creating trigger TRG_TB_SYSFILE 替换后 变成 Creating trigger TRG_TB_SYSFILE_NEW
正则表达式:(TB_SYS[^\.]+\b)
替换表达式:$1_NEW
说明:
$0,其中$0表示正则匹配的整个最大字符串值。
$1,表示在查找的表达式中查找到的第一个()指定的字符。
$2,表示在查找的表达式中查找到的第二个()指定的字符。
...
$n,表示在查找的表达式中查找到的第n个()指定的字符。
特别注意:这里替换的时候,只能手动点击一个一个替换,不能全部一次替换!!!
附 图片中实际操作文本:
------------------------------------------
-- Export file for user DZDA --
-- Created by ym on //, :: --
------------------------------------------ set define off
spool dzda_sys_trg.log prompt
prompt Creating trigger TRG_TB_SYSFILE
prompt ===============================
prompt
create or replace trigger dzda.TRG_TB_SYSFILE
before insert ON TB_SYSFILE
for each row
when (new.id is null)
begin
select SEQ_TB_SYSFILE.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSIPBLACK
prompt ==================================
prompt
create or replace trigger dzda.trg_tb_sysipblack
before insert ON tb_sysipblack
for each row
when (new.id is null)
begin
select seq_tb_sysipblack.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSLOGINLOG
prompt ===================================
prompt
create or replace trigger dzda.trg_tb_sysloginlog
before insert ON tb_sysloginlog
for each row
when (new.id is null)
begin
select seq_tb_sysloginlog.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSLOGOPERATION
prompt =======================================
prompt
create or replace trigger dzda.trg_tb_syslogoperation
before insert ON tb_syslogoperation
for each row
when (new.id is null)
begin
select seq_tb_syslogoperation.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSLOGSETTING
prompt =====================================
prompt
create or replace trigger dzda.trg_tb_syslogsetting
before insert ON tb_syslogsetting
for each row
when (new.logid is null)
begin
select seq_tb_syslogsetting.nextval into :new.logid from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSLOGSETTINGDETAIL
prompt ===========================================
prompt
create or replace trigger dzda.trg_tb_syslogsettingdetail
before insert ON tb_syslogsettingdetail
for each row
when (new.id is null)
begin
select seq_tb_syslogsettingdetail.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSMENU
prompt ===============================
prompt
create or replace trigger dzda.TRG_TB_SYSMENU before
insert on TB_SYSMENU for each row
when (new.id is null)
begin
select SEQ_TB_SYSMENU.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSORGANIZATION
prompt =======================================
prompt
create or replace trigger dzda.trg_tb_SysOrganization
before insert ON tb_SysOrganization
for each row
when (new.id is null)
begin
select seq_tb_SysOrganization.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSPARAMETER
prompt ====================================
prompt
create or replace trigger dzda.trg_tb_sysparameter
before insert ON tb_sysparameter
for each row
when (new.id is null)
begin
select seq_tb_sysparameter.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSPERMISSIONS
prompt ======================================
prompt
create or replace trigger dzda.trg_tb_syspermissions
before insert ON tb_syspermissions
for each row
when (new.id is null)
begin
select seq_tb_syspermissions.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSPLUGIN
prompt =================================
prompt
create or replace trigger dzda.trg_tb_sysplugin
before insert ON tb_sysplugin
for each row
when (new.id is null)
begin
select seq_tb_sysplugin.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSROLE
prompt ===============================
prompt
create or replace trigger dzda.trg_tb_sysrole
before insert ON tb_sysrole
for each row
when (new.id is null)
begin
select seq_tb_sysrole.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSROLEPERMISSIONS
prompt ==========================================
prompt
create or replace trigger dzda.trg_tb_sysrolepermissions
before insert ON tb_sysrolepermissions
for each row
when (new.id is null)
begin
select seq_tb_sysrolepermissions.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYSUSER
prompt ===============================
prompt
create or replace trigger dzda.trg_tb_sysuser
before insert ON tb_sysuser
for each row
when (new.id is null)
begin
select seq_tb_sysuser.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYS_ERROR_LOG
prompt =====================================
prompt
create or replace trigger dzda.TRG_TB_SYS_ERROR_LOG before
insert on TB_SYS_ERROR_LOG for each row
when (new.id is null)
begin
select SEQ_TB_SYS_ERROR_LOG.nextval into :new.id from dual;
end;
/ prompt
prompt Creating trigger TRG_TB_SYS_LWLOG
prompt =================================
prompt
create or replace trigger dzda.TRG_TB_SYS_LWLOG before
insert on TB_SYS_LWLOG for each row
when (new.id is null)
begin
select SEQ_TB_SYS_LWLOG.nextval into :new.id from dual;
end;
/ spool off