duan39779 2015-12-12 13:59
浏览 118
已采纳

MySQL regexp不检测等号

I got a mysql database that I am trying to find some urls using REGEXP.

However, my regex does not seem to work, right at the equals sign.

An example field would be:

POST /4jEFhi.php?p=o2k8q6j5dm9pau HTTP/1.1 ~~ Host: example.com ~~ User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)

MY initial regex looks like this:

^POST /(?![a-z_]{6})[A-Za-z0-9_]{6}.php\?[a-z]=[a-z0-9]{10,}

However, in mysql workbench and or phpmyadmin, I face the same problems.

First, this piece:

(?![a-z_]{6})

Does not work in MySQL, I get the following error:

Error Code: 1139. Got error 'repetition-operator operand invalid' from regexp

If I remove it, I seem to be good to continue with

^POST /[A-Za-z0-9_]{6}.php\?[a-z]=[a-z0-9]{10,}

However,The detection seems to stop at the = (equals-sign)

This works, but not as precise:

^POST /(?![a-z_]{6})[A-Za-z0-9_]{6}.php\?[a-z]

Any help correcting this is appreciated, because my googling skills have hit the wall.

  • 写回答

1条回答 默认 最新

  • dongliao9233 2015-12-12 14:49
    关注

    Try:

    SET @`URL`    := 'POST /4jEFhi.php?p=o2k8q6j5dm9pau HTTP/1.1 ~~ Host: example.com ~~ User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)',
        @`REGEXP` := '^POST /[A-Za-z0-9_]{6}\\.php\\?[a-z]\\=[a-z0-9]{10,}';
    
    SELECT @`URL` REGEXP BINARY @`REGEXP`;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码