问大家一个问题,如何写一个正则,使它匹配所有
类似youshang.com的网址,但除club.youshang.com这类网址以外

解决方案 »

  1.   

    SELECT * from tablename where url <> 'club.youshang.com' and url REGEXP '^[[:alnum:]]+\.youshang\.com$';  
      

  2.   

    简单点的。select * from a where `name` regexp '^.*(http://youshang.com){1}.*$';
      

  3.   

    非常感谢楼上的两位,我这里面不能用AND 才想到用正则的
    4楼的没有明白我的意思,我再讲明白点:我其实要的效果是:  select * from a where `name` where name like '%youshang.com%' and  name not like '%club.youshang.com%'
    由于某种原因,现在我想就用一个正则来搞定,但不知道如何写? 
      

  4.   

    你可能要的是这个sql吧select * from a where `name` where name regexp '.*[^club]\.youshang.com'
      

  5.   


    select * from a where `name` where name regexp '.*[^club]\.youshang\.com.*'
      

  6.   

    又弄错了,汗……select * from a where `name` where name regexp '[^club]\.youshang.com'
      

  7.   

    错,这会把 c.youshang.com  b.youshang.com 等过滤了
      

  8.   

    楼主的意思是这样吧。
    select * from a where `name` regexp '^[^\.]*(youshang.com)+.*$'