首页 \ 问答 \ 在php中匹配未转义的字符(match unescaped characters in php)

在php中匹配未转义的字符(match unescaped characters in php)

我需要一个正则表达式来匹配PHP中的单个/字符串。

"bla bla bla/bla bla bla" //The regexp must match the / character
"bla bla // bla bla / bla bla" //The regexp must match only the last / not the first beacuse it is followed by another /

所以我只希望没有转义/。


i need a regexp to match only single / in a string in PHP.

"bla bla bla/bla bla bla" //The regexp must match the / character
"bla bla // bla bla / bla bla" //The regexp must match only the last / not the first beacuse it is followed by another /

so i want only unescaped /.


原文:https://stackoverflow.com/questions/1345618
更新时间:2023-06-03 14:06

最满意答案

我认为你的第二个触发器需要使用实际表中的值,而不是插入/删除的表来填充日志表 - 插入/删除将始终具有未更改的原始值,而更改的值将显示在表中。 使第二个触发器成为“After”触发器,因此您不必使用sp_settriggerorder。 像这样,例如:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trg_Trig1] 
   ON  [dbo].[TestTable] 
   FOR INSERT
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    update TestTable
    set [value] = 10
    where [value] = 25

END

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trg_Trig2]
   ON  [dbo].[TestTable] 
   AFTER INSERT
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here
    insert into log_TestTable
    (id, description, [value])
    select tt.id, tt.description, tt.[value]
    from inserted i
        LEFT JOIN TestTable tt
            ON tt.id = i.id

END

I think your second trigger needs to use the values from the actual table, not the inserted/deleted tables to populate the log table - inserted/deleted will always have the unaltered, original values, while your altered values will appear in the table. Make the second trigger an "After" trigger, so you will not have to use the sp_settriggerorder. Like this, for example:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trg_Trig1] 
   ON  [dbo].[TestTable] 
   FOR INSERT
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    update TestTable
    set [value] = 10
    where [value] = 25

END

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[trg_Trig2]
   ON  [dbo].[TestTable] 
   AFTER INSERT
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for trigger here
    insert into log_TestTable
    (id, description, [value])
    select tt.id, tt.description, tt.[value]
    from inserted i
        LEFT JOIN TestTable tt
            ON tt.id = i.id

END

相关问答

更多
  • 我认为你的第二个触发器需要使用实际表中的值,而不是插入/删除的表来填充日志表 - 插入/删除将始终具有未更改的原始值,而更改的值将显示在表中。 使第二个触发器成为“After”触发器,因此您不必使用sp_settriggerorder。 像这样,例如: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[trg_Trig1] ON [dbo].[TestTable] FOR INSERT AS BE ...
  • 你的google-fu弱我的朋友: http : //dev.mysql.com/doc/refman/5.0/en/create-trigger.html但你最终会学到:) 虽然如果这不是一个专门用于创建触发器的项目,但我不建议使用它们。 由于这个“将自动将此更改记录到另一个名为”的表,肯定可以在业务逻辑中完成。 然后,您可以控制从软件和用户完成的操作。 也许在不久的将来,您需要在表上执行datafix - 然后您必须禁用触发器,执行修复并再次启用它。 这似乎是你真的不想做的很多工作。 因此,如果可能的话 ...
  • 表中的行(物理上在数据库中)的顺序由聚簇索引决定。 把它放在name_software列上,就是这样。 但 1)你真的不需要像这样对表格中的数据进行排序。 它是一个数据库...... :)您可以通过查询对其进行排序。 2)聚集索引通常在主键上,当然只能在表上有一个... The order of rows in a table (physically in the database) is decided by a clustered index. Put one on the name_software ...
  • 对于案例1 ,如果重复检测未找到任何重复项,则不应执行插入,正常插入将执行此操作 CREATE TRIGGER `trig_no_dup` BEFORE INSERT ON `Demo` FOR EACH ROW BEGIN SET @Counter = (SELECT COUNT(*) FROM `Demo` WHERE `StoreID` = NEW.StoreID AND `Code` = NEW.Code AND `Status` = 'Active'); - ...
  • after insert需要触发器 delimiter // create trigger total_sum after insert on meter5 for each row begin insert into hourly (id,vrms,irms,total) values (new.id,new.vrms,new.irms,new.vrms*new.irms); end ; // delimiter ; You need the trigger to be after insert so ...
  • 感谢e4c5。 最佳解决方案是创建VIEW: CREATE TABLE IF NOT EXISTS `table2` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `t2col1` int(11) DEFAULT 0, `t2col2` int(11) DEFAULT 0, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; INSERT INTO `tab ...
  • 是的,你不能这样做。 Mysql就是这种方式可以防止循环循环和内存问题...就像更新正在解析的游标一样:某些引擎允许它,其他引擎则不行。 Yeah, you just can't do that. Mysql is this way preventing circular loops and memory issues... It is like updating a cursor being parsed: some engines allow it, others no.
  • 引用文档 : 检测触发触发器的DML操作 如果多种类型的DML操作可以触发触发器(例如,ON INSERT OR DELETE OR UPDATE OF emp),则触发器主体可以使用条件谓词INSERTING,DELETING和UPDATING来检查触发器的哪种类型的语句。 在触发器主体的代码中,您可以根据触发触发器的DML操作的类型执行代码块: IF INSERTING THEN ... END IF; IF UPDATING THEN ... END IF; Quoting the docs: De ...
  • 我可以通过存储过程来显示它。 这个概念是从wchiquito的答案中解脱出来的。 我相信你会发现这是一个更详尽的答案。 这只是一个例子。 根据您的特定需求(其他触发器类型)等进行必要的更改。如何执行mysql触发器信号在不使用存储过程之外触发是任何人的猜测。 因此,如果您不愿意或无法执行存储过程, 请不要继续阅读 。 请注意,为方便起见,我们会留下任何掉落或截断的内容。 架构 create database trigTranTest; -- creates a separate database for ...
  • 我知道只有两种方法可以做到这一点而且都没有触发。 您可以使用存储过程来运行查询,并将查询记录到表中以及您想要了解的其他信息。 您可以使用SQL Server的审核功能 。 我从来没有使用过后者,所以我不能说易用性。 There are only two ways I know that you can do this and neither are trigger. You can use a stored procedure to run the query and log the query to a ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。