overlapping-matches

Overlapping matches with finditer() in Python

余生颓废 提交于 2019-12-02 00:18:20
I'm using a regex to match Bible verse references in a text. The current regex is REF_REGEX = re.compile(''' (?<!\w) # Not preceded by any words (?P<quote>q(?:uote)?\s+)? # Match optional 'q' or 'quote' followed by many spaces (?P<book> (?:(?:[1-3]|I{1,3})\s*)? # Match an optional arabic or roman number between 1 and 3. [A-Za-z]+ # Match any alphabetics )\.? # Followed by an optional dot (?: \s*(?P<chapter>\d+) # Match the chapter number (?: [:\.](?P<startverse>\d+) # Match the starting verse number, preceded by ':' or '.' (?:-(?P<endverse>\d+))? # Match the optional ending verse number,

Overlapping regex matches

ぃ、小莉子 提交于 2019-11-29 16:31:46
I'm trying to create the following regular expression: return a string between AUG and ( UAG or UGA or UAA ) from a following RNA string: AGCCAUGUAGCUAACUCAGGUUACAUGGGGAUGACCCCGCGACUUGGAUUAGAGUCUCUUUUGGAAUAAGCCUGAAUGAUCCGAGUAGCAUCUCAG , so that all matches would be found, including the overlapping ones. I've tried several regexes, ending up with something like that: matches = re.findall('(?=AUG)(\w+)(?=UAG|UGA|UAA)',"AGCCAUGUAGCUAACUCAGGUUACAUGGGGAUGACCCCGCGACUUGGAUUAGAGUCUCUUUUGGAAUAAGCCUGAAUGAUCCGAGUAGCAUCUCAG") Could you show me the errors in my regex pattern? Doing this with one regular

Check overlap of date ranges in MySQL

断了今生、忘了曾经 提交于 2019-11-26 00:41:08
问题 This table is used to store sessions (events): CREATE TABLE session ( id int(11) NOT NULL AUTO_INCREMENT , start_date date , end_date date ); INSERT INTO session (start_date, end_date) VALUES (\"2010-01-01\", \"2010-01-10\") , (\"2010-01-20\", \"2010-01-30\") , (\"2010-02-01\", \"2010-02-15\") ; We don\'t want to have conflict between ranges. Let\'s say we need to insert a new session from 2010-01-05 to 2010-01-25 . We would like to know the conflicting session(s). Here is my query: SELECT *