简体   繁体   English

mysql查询中的regex

[英]REGEX in mysql query

I won't found data from table who start following by CR and one space and 4 to 6 number 我从表中找不到以CR和一个空格以及4到6开头的数据

Query 询问

SELECT `order_det_ref_no` FROM `manufacturers_order` WHERE
`order_det_ref_no` REGEXP '%^CR\s+\b\w{4,6}$%'

在此处输入图片说明

MySQL regex does not use regex delimiters, nor does it support \\b (it uses [[:<:]] for a word start position and [[:>:]] for a word end), \\s , \\w regex shorthand classes. MySQL regex不使用regex分隔符,也不支持\\b (它将[[:<:]]用作单词开始位置,将[[:>:]]用作单词结尾), \\s\\w regex速记类。 Use 采用

REGEXP '^CR[[:space:]]+[[:alnum:]_]{4,6}$'

Note that [[:space:]] matches both horizontal and vertical whitespace, you may use [[:blank:]] if you also need to only match horizontal whitespace. 请注意, [[:space:]]匹配水平和垂直空白,如果您还只需要匹配水平空白,则可以使用[[:blank:]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM