dongzanghua8422 2014-08-20 09:53
浏览 7

preg_match不能用作过滤器,请查看详细信息

My database stores a message (string) and its corresponding regex which replaces some variable information (like date, amount, etc). Once the regex has been identified and stored in the database, all the messages similar to the one in the database (regex) should be filtered out (using preg_match()). However, when I store the following in my database, the similar messages aren't getting filtered out.

$message = Payment received NEFT - Your account account_number has been credited for some_amount from some_sender vide Txn ref some_ref_num.

$corresponding_regex = Payment received NEFT \- Your account (.*) has been credited for (.*) from (.*) vide Txn ref (.*)

I am guessing the problem is with 'NEFT'. Because, if I remove it, the similar messages get filtered out. But, I can't replace NEFT with (.*) as that information is essential for me.

How do I ensure that the similar messages get filtered out without replacing NEFT from my regex?

  • 写回答

1条回答 默认 最新

  • doujun7161 2014-08-20 09:56
    关注

    Change (.*) in your regex to (\S+),

    Payment received NEFT \- Your account (\S+) has been credited for (\S+) from (\S+) vide Txn ref (\S+)
    

    DEMO

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?