简体   繁体   中英

Match a specific string in Python except if it a given pattern is missing

This question might have already been asked, but I have found any solution so far.

I want to match strings that contain inhibition(.+)toxicity but I do not want to match growth inhibition(.+)toxicity .

I tried (!?growth )inhibition(.+)toxicity but it returns the string I want to exclude. However, using (!?growth) returns everything except the strings containing growth.

I do not understand what I am doing wrong with this regex.

EDIT: add example

string I want to mach: Inhibition of recombinant human TNF-alpha-induced cytotoxicity of mouse L929 cells

string I do not want to match: Evaluated for the inhibitory concentration required to cause growth inhibition of A427Mer- cell line of lung using the MTT Cytotoxicity Assay

There is a syntax error. The correct regex is:

(?<!growth )inhibition(.+)toxicity

Take a look at Regex Tutorial - Lookahead and Lookbehind Zero-Length Assertions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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