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`;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)