开发者

mysql regular expression

开发者 https://www.devze.com 2023-02-18 11:45 出处:网络
I found this query in mysql query log and I will like to know what exactly does it do. select * from tblname WHERE TRIM(NAME) REGEXP \'John[]*S开发者_运维百科mith\'

I found this query in mysql query log and I will like to know what exactly does it do.

select * from tblname WHERE TRIM(NAME) REGEXP 'John[      ]*S开发者_运维百科mith'


It selects all rows from tblname where name (with spaces around removed, if any) equals to John<any number of spaces>Smith

So you'll find JohnSmith as well as John_________________________Smith (stackoverflow eats repetitive spaces, so I replaced them with underscore).

The regex itself is a little bloated and can be rewritten as John *Smith

0

精彩评论

暂无评论...
验证码 换一张
取 消