这是我的查询确实有效:
select composition from `drugs` where composition regexp "^Diclofenac([^)])"
输出:
Diclofenac(50mg),Thiocolchicoside(8mg)
Diclofenac(50mg),Thiocolchicoside(4mg)
Diclofenac(75mg),Thiocolchicoside(4mg)
Diclofenac(50mg),Thiocolchicoside(4mg)
Diclofenac(50mg),Tamsulosin(0.4mg)
Diclofenac(50mg),Eperisone(50mg)
Diclofenac(50mg),Thiocolchicoside(8mg)
Diclofenac(100mg),Rabeprazole(20mg)
Diclofenac(75mg)
Diclofenac(50mg),Thiocolchicoside(8mg)
Diclofenac(50mg),Serratiopeptidase(10mg)
Diclofenac(100mg),Eperisone(150mg)
Diclofenac(4mg),Thiocolchicoside(50mg)
Diclofenac(100mg),Eperisone(150mg)
Diclofenac(50mg),Thiocolchicoside(4mg)
Diclofenac(50mg),Thiocolchicoside(8mg)
Diclofenac(50mg),Nimesulide(100mg)
Diclofenac(50mg),Paracetamol(325mg),Thiocolchicoside(8mg)
Diclofenac(NA),Serratiopeptidase(NA)
Diclofenac(50mg),Nimesulide(100mg)
Diclofenac(50mg),Thiocolchicoside(4mg)
Diclofenac(50mg),Paracetamol(325mg),Thiocolchicoside(4mg)
Diclofenac(100mg),Rabeprazole(20mg)
Diclofenac(50mg),Serratiopeptidase(10mg)
Diclofenac(50mg),Nimesulide(100mg)
我想寻找药物,其中组合物以Diclofenac()开头,然后是",#34;其次是硫代秋水仙碱苷()。试过以下但结果为零。
select composition from `drugs` where composition regexp "^Diclofenac([^)]),Thiocolchicoside([^)])"
编辑: 创建了DB小提琴:https://www.db-fiddle.com/f/fkQkn2WKdax2KbZqt7rPQ/0
答案 0 :(得分:1)
select composition from `drugs` where composition regexp "^Diclofenac\\([^)]+\\),Thiocolchicoside\\([^)]+\\)$"
除了添加' +'为了匹配多个非右支撑字符,即[^]],你需要转义'(',因为它在正则表达式中有特殊含义
答案 1 :(得分:0)
尝试此模式^Diclofenac(.*,Thiocolchicoside\(.*\))
.*,
表示,
\(.*\)
表示(括号中的任何内容)