Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

78.8 KB
Raw Blame
"""Quote handling in PubMed query optimization (issue #7278).

The optimizer drops every double quote from the query when each one is a
stray closer: directly after a character that is not whitespace (including
zero-width spaces and BOM) or "(", and directly before "[" and a letter, as
in vaccine"[tiab]. Everything else must behave exactly as before: the
regression corpus pins every response shape collected while reviewing
earlier, broader attempts at this fix to the output of the unchanged
pipeline.
"""

from unittest.mock import Mock

import pytest

from local_deep_research.web_search_engines.engines.search_engine_pubmed import (
    PubMedSearchEngine,
)

# (LLM response, optimized query) pairs. The expected values are the output
# of the pipeline before this fix; none of these responses is affected by it.
CORPUS = [
    ("here's", "here's"),
    ('"+', '"+'),
    ("[", "["),
    (")([,:", ")([,:"),
    ('("[^"]*")', '("[^"]*")'),
    ('"heart attack"AND "x y"', 'heart attack"AND "x y'),
    ('NOT"foo bar"', 'NOT"foo bar"'),
    ('("a b")OR("c d")', '("a b")OR("c d")'),
    ('"a b".', '"a b".'),
    ('"a b"-"c d"', 'a b"-"c d'),
    ('-"foo bar"', '-"foo bar"'),
    ('"a b"* AND c', '"a b"* AND c'),
    ('"a b"; "c d"', 'a b"; "c d'),
    ('"foo bar"/"baz qux"', 'foo bar"/"baz qux'),
    ('"it\'s" OR "x"', 'it\'s" OR "x'),
    ("“foo bar”[ti]", "“foo bar”[ti]"),
    ('"a b"[ti]AND"c d"[ti]', '"a b"[ti]AND"c d"[ti]'),
    ('"a b"[ti]OR"c d"[ti]', '"a b"[ti]OR"c d"[ti]'),
    ('"a b"~3', '"a b"~3'),
    ("'foo bar'[ti]", "'foo bar'[ti]"),
    ('(("a b")AND("c d"))', '(("a b")AND("c d"))'),
    ('"a b"\t"c d"', 'a b"\t"c d'),
    ('"2020"[dp]:"2025"[dp]', '"2020"[dp]:"2025"[dp]'),
    ("a [mj] b", "a [mj] b"),
    ("a [is] b", "a [is] b"),
    ("a [dep] b", "a [dep] b"),
    ("a [jt] b", "a [jt] b"),
    ("a [so] b", "a [so] b"),
    ("a [ab] b", "a [ab] b"),
    ("a [MeSH Major Topic:noexp] b", "a [MeSH Major Topic:noexp] b"),
    ("a [Mesh: noexp] b", "a [Mesh: noexp] b"),
    ("a [mesh terms : noexp] b", "a [mesh terms : noexp] b"),
    ("a [ Mesh ] b", "a [ Mesh ] b"),
    ("a [Title/Abstract ] b", "a [Title/Abstract ] b"),
    ("a [bk] b", "a [bk] b"),
    ("a [tiab:~3] b", "a [tiab:~3] b"),
    ("a [Author - Corporate] b", "a [Author - Corporate] b"),
    ("a [Journal Article] b", "a [Journal Article] b"),
    ("a [pt] b", "a [pt] b"),
    ('x [Mesh]"y"', 'x [Mesh]"y"'),
    ('a "b" c "d', 'a "b" c "d'),
    ('"" ab()[]:', '"" ab()[]:'),
    ('"a" b" c"', 'a" b" c'),
    ('x "a b" y"', 'x "a b" y"'),
    ('"a" "b"', 'a" "b'),
    ('He said "hi"there', 'He said "hi"there'),
    ('"foo"bar baz"', 'foo"bar baz'),
    ('"cancer treatment" AND "breast"', 'cancer treatment" AND "breast'),
    ('5" pipe AND "x y"', '5" pipe AND "x y"'),
    ('"a"[ti]', '"a"[ti]'),
    ('"(a" OR b)', '"(a" OR b)'),
    ('vaccine "a b"c', 'vaccine "a b"c'),
    ('""', ""),
    ('"', ""),
    ('"""a"""', '""a""'),
    ('"a ""b"" c"', 'a ""b"" c'),
    ('"x"[Title/Abstract]"y"', 'x"[Title/Abstract]"y'),
    ('"hip pain"[Title:~3]', '"hip pain"[Title:~3]'),
    ('"smith"[Author - First]', '"smith"[Author - First]'),
    ('"x"/"y"', 'x"/"y'),
    ("cancer [MeSH Terms] x", "cancer [MeSH Terms] x"),
    ("cancer [mesh terms:noexp] y", "cancer [mesh terms:noexp] y"),
    ("a [Majr] b", "a [Majr] b"),
    ("a [sh] b", "a [sh] b"),
    ("a [tw] b", "a [tw] b"),
    ("a [Filter] b", "a [Filter] b"),
    ("a [sb] b", "a [sb] b"),
    ("a [Title/Abstract] b", "a [Title/Abstract] b"),
    ("a [Mesh:NoExp] b", "a [Mesh:NoExp] b"),
    ("a [Mesh Terms] b", "a [Mesh Terms] b"),
    ("a [MeSH Subheading] b", "a [MeSH Subheading] b"),
    ("a [All Fields] b", "a [All Fields] b"),
    ("a [nonsense] b", "a [nonsense] b"),
    ("a [lang] b", "a [lang] b"),
    ("a [Language] b", "a [Language] b"),
    ("a [la] b", "a [la] b"),
    ("a [dp] b", "a [dp] b"),
    ("a [ti:~3] b", "a [ti:~3] b"),
    ("a [Supplementary Concept] b", "a [Supplementary Concept] b"),
    ("a [pt]", "a [pt]"),
    ("a [tiab] b", "a [tiab] b"),
    ("a [mesh:noexp]", "a [mesh:noexp]"),
    ("a [PDAT] b", "a [PDAT] b"),
    ("a [Date - Publication] b", "a [Date - Publication] b"),
    ("a [subset] b", "a [subset] b"),
    ("a [Subset] b", "a [Subset] b"),
    ("a [text] b", "a [text] b"),
    ("a [Text Word] b", "a [Text Word] b"),
    ("a [title] b", "a [title] b"),
    ("a [Abstract] b", "a [Abstract] b"),
    ("a [TIAB]", "a [TIAB]"),
    ("a [Affiliation]", "a [Affiliation]"),
    ("a [Author]", "a [Author]"),
    ("a [DOI]", "a [DOI]"),
    ("a [doi]", "a [doi]"),
    ("a [ISSN]", "a [ISSN]"),
    ("a [issn]", "a [issn]"),
    ("a [Volume]", "a [Volume]"),
    ("a [Issue]", "a [Issue]"),
    ("a [jour]", "a [jour]"),
    ("a [ptyp]", "a [ptyp]"),
    ("a [EDAT]", "a [EDAT]"),
    ("a [MHDA]", "a [MHDA]"),
    ("a [pmcid]", "a [pmcid]"),
    ("a [Place of Publication]", "a [Place of Publication]"),
    ("a [Pharmacological Action]", "a [Pharmacological Action]"),
    ("a [Personal Name as Subject]", "a [Personal Name as Subject]"),
    ("a [Title/Abstract:~3]", "a [Title/Abstract:~3]"),
    ("a [ISBN]", "a [ISBN]"),
    ("a [Other Term]", "a [Other Term]"),
    ("a [Language]", "a [Language]"),
    ("a [Grant Number]", "a [Grant Number]"),
    ("a [Investigator]", "a [Investigator]"),
    ("a [Full Investigator Name]", "a [Full Investigator Name]"),
    ("a [Journal]", "a [Journal]"),
    ("a [Corporate Author]", "a [Corporate Author]"),
    ("a [MeSH Major Topic]", "a [MeSH Major Topic]"),
    ("a [Mesh Major Topic]", "a [Mesh Major Topic]"),
    ("a [Publication Date]", "a [Publication Date]"),
    ("a [Date of Publication]", "a [Date of Publication]"),
    ("a [Entrez Date]", "a [Entrez Date]"),
    ("a [Transliterated Title]", "a [Transliterated Title]"),
    ("a [Secondary Source ID]", "a [Secondary Source ID]"),
    ("a [Author Identifier]", "a [Author Identifier]"),
    ("a [ORCID]", "a [ORCID]"),
    ("a [Last Author]", "a [Last Author]"),
    ("a [First Author]", "a [First Author]"),
    ("a [Last Author Name]", "a [Last Author Name]"),
    ("a [Pagination]", "a [Pagination]"),
    ("a [Page]", "a [Page]"),
    ("a [Title]", "a [Title]"),
    ("a [MeSH Date]", "a [MeSH Date]"),
    ("a [Modification Date]", "a [Modification Date]"),
    ("a [Text Words]", "a [Text Words]"),
    ("a [Book]", "a [Book]"),
    ("a [Collection Title]", "a [Collection Title]"),
    ("a [NLM Unique ID]", "a [NLM Unique ID]"),
    ("a [Not]", "a [Not]"),
    ("a [Humans]", "a [Humans]"),
    ('NOT"mice"[Mesh] AND cancer[tiab]', 'NOT"mice"[Mesh] AND cancer[tiab]'),
    (
        '("heart attack"OR"cardiac arrest") AND aspirin[tiab]',
        '("heart attack"OR"cardiac arrest") AND aspirin[tiab]',
    ),
    (
        '"vaccin*"[tiab] AND "elderly"[tiab]',
        '"vaccin*"[tiab] AND "elderly"[tiab]',
    ),
    ('"mRNA vaccine"* AND elderly', '"mRNA vaccine"* AND elderly'),
    ('"cancer"; therapy[tiab]', '"cancer"; therapy[tiab]'),
    (
        '"Neoplasms/therapy"[Mesh] AND aspirin[tiab]',
        '"Neoplasms/therapy"[Mesh] AND aspirin[tiab]',
    ),
    ('"Vaccines"[Mesh].', '"Vaccines"[Mesh].'),
    (
        'cancer[tiab] AND "breast neoplasms"/therapy[Mesh]',
        'cancer[tiab] AND "breast neoplasms"/therapy[Mesh]',
    ),
    ('-"mice" AND cancer', '-"mice" AND cancer'),
    ('cancer[tiab] AND "mRNA vaccine"!', 'cancer[tiab] AND "mRNA vaccine"!'),
    (
        '"COVID-19"[Mesh] AND ("long COVID"[tiab] OR "post-acute sequelae"[tiab])',
        '"COVID-19"[Mesh] AND ("long COVID"[tiab] OR "post-acute sequelae"[tiab])',
    ),
    (
        "(“mRNA vaccine”[tiab]) AND elderly",
        "(“mRNA vaccine”[tiab]) AND elderly",
    ),
    (
        '"mRNA vaccine"[tiab]AND elderly[tiab]',
        '"mRNA vaccine"[tiab]AND elderly[tiab]',
    ),
    (
        'cancer AND "mRNA vaccine"[tiab]OR elderly',
        'cancer AND "mRNA vaccine"[tiab]OR elderly',
    ),
    (
        '"Here\'s the query: cancer[Mesh] AND therapy"',
        "cancer[Mesh] AND therapy",
    ),
    ('"The following: cancer"', "cancer"),
    ('"cancer[Mesh]"', "cancer[Mesh]"),
    ('"[Mesh]"', "[Mesh]"),
    ('"Vaccines[Mesh] AND Aged[Mesh]"', "Vaccines[Mesh] AND Aged[Mesh]"),
    (
        '"Neoplasms"[Mesh:NoExp] AND therapy',
        '"Neoplasms"[Mesh:NoExp] AND therapy',
    ),
    (
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
    ),
    (
        '"alpha [beta] gamma"[Title/Abstract]',
        '"alpha "[beta] gamma"[Title/Abstract]',
    ),
    ('"2[18F]FDG uptake"', "2[18F]FDG uptake"),
    ('"[18F]FDG uptake"', "[18F]FDG uptake"),
    ('"ATP[32P] binding"', "ATP[32P] binding"),
    ('"alpha[beta] gamma"', "alpha[beta] gamma"),
    ('"sodium [Na+] transport"', "sodium [Na+] transport"),
    (
        '"2[18F]FDG uptake"[Title/Abstract]',
        '"2"[18F]FDG uptake"[Title/Abstract]',
    ),
    (
        '"a[b" AND vaccin*[Title/Abstract]',
        '"a"[b" AND vaccin*"[Title/Abstract]',
    ),
    (
        '"alpha [mesh] gamma"[Title/Abstract]',
        '"alpha "[Mesh] gamma"[Title/Abstract]',
    ),
    ('"alpha [beta] AND gamma"', "alpha [beta] AND gamma"),
    ('"cancer immunotherapy"', "cancer immunotherapy"),
    (
        '"Review"[Publication Type] AND "cancer treatment"',
        'Review"[Publication Type] AND "cancer treatment',
    ),
    ('"smith j"[au] AND "science"[ta]', '"smith j"[au] AND "science"[ta]'),
    ('"hip  pain"[Title:~3]', '"hip  pain"[Title:~3]'),
    (
        '("heart attack" OR "cardiac arrest") AND NOT mice[Mesh]',
        '("heart attack" OR "cardiac arrest") AND NOT mice[Mesh]',
    ),
    ('"2020/01/01":"2025/12/31"[dp]', '"2020/01/01":"2025/12/31"[dp]'),
    (
        '"alpha [mesh]  gamma"[Title/Abstract] AND "Review"[Publication Type]',
        '"alpha "[Mesh]  gamma"[Title/Abstract] AND "Review"[Publication Type]',
    ),
    (
        '(vaccine"[Mesh] OR "alpha [Mesh] gamma"[Title/Abstract])',
        '(vaccine"[Mesh] OR "alpha [Mesh] gamma"[Title/Abstract])',
    ),
    (
        '(vaccine"[Mesh] OR "alpha [beta] gamma"[Title/Abstract])',
        '(vaccine"[Mesh] OR "alpha [beta] gamma"[Title/Abstract])',
    ),
    ("smith j[au] AND cancer[tiab]", "smith j[au] AND cancer[tiab]"),
    ("smith j [1au] AND cancer [Title]", "smith j [1au] AND cancer [Title]"),
    (
        "smith j[Author] AND science[Journal]",
        "smith j[Author] AND science[Journal]",
    ),
    (
        "cancer[MeSH Terms:noexp] AND review[pt]",
        "cancer[MeSH Terms:noexp] AND review[pt]",
    ),
    ("cancer [mh:noexp] AND 2025 [dp]", "cancer [mh:noexp] AND 2025 [dp]"),
    ("cancer [Date - Publication]", "cancer [Date - Publication]"),
    ("cancer [Publication Date]", "cancer [Publication Date]"),
    ("cancer [pmid]", "cancer [pmid]"),
    ("cancer [Text Word]", "cancer [Text Word]"),
    ("cancer [Other Term]", "cancer [Other Term]"),
    ('"cancer[Mesh] AND treatment"', "cancer[Mesh] AND treatment"),
    ('"cancer [Mesh] AND treatment"', "cancer [Mesh] AND treatment"),
    (
        "(vaccine[Title/Abstract] OR immunization[Title/Abstract]) AND influenza[Title/Abstract]",
        "(vaccine[Title/Abstract] OR immunization[Title/Abstract]) AND influenza[Title/Abstract]",
    ),
    ('"messenger RNA[Title/Abstract]', '"messenger RNA"[Title/Abstract]'),
    ("messenger RNA[Title/Abstract]", "messenger RNA[Title/Abstract]"),
    ('"alpha beta AND gamma', '"alpha beta AND gamma'),
    ('alpha beta"', 'alpha beta"'),
    ('vaccine"""', 'vaccine"""'),
    ('vaccine""booster"', 'vaccine""booster"'),
    ('"""vaccine', '"""vaccine'),
    (
        '"leaky OR "good phrase" AND vaccin*[Title/Abstract]',
        '"leaky OR "good phrase" AND vaccin*"[Title/Abstract]',
    ),
    (
        'leaky OR "good phrase" AND vaccin*[Title/Abstract]',
        'leaky OR "good phrase" AND vaccin*[Title/Abstract]',
    ),
    (
        '"mRNA vaccine"[Mesh] AND "messenger RNA[Title/Abstract]',
        '"mRNA vaccine"[Mesh] AND "messenger RNA"[Title/Abstract]',
    ),
    (
        '"mRNA vaccine"[Mesh] AND messenger RNA[Title/Abstract]',
        '"mRNA vaccine"[Mesh] AND messenger RNA[Title/Abstract]',
    ),
    ('"2[18F]FDG uptake[Title/Abstract]', '"2[18F]FDG uptake"[Title/Abstract]'),
    ("2[18F]FDG uptake[Title/Abstract]", "2[18F]FDG uptake[Title/Abstract]"),
    (
        'vaccine"[Title/Abstract] OR "good phrase"[Mesh]',
        'vaccine"[Title/Abstract] OR "good phrase"[Mesh]',
    ),
    (
        'vaccine[Title/Abstract] OR "good phrase"[Mesh]',
        'vaccine[Title/Abstract] OR "good phrase"[Mesh]',
    ),
    (
        '"alpha [mesh]  gamma"[title/abstract] AND "Review"[publication type]',
        '"alpha "[Mesh]  gamma"[Title/Abstract] AND "Review"[Publication Type]',
    ),
    (
        '"alpha [mesh]  gamma"[Title/Abstract] AND "Review"',
        'alpha [Mesh]  gamma"[Title/Abstract] AND "Review',
    ),
    ('"cancer[Title/Abstract]"', "cancer[Title/Abstract]"),
    ("cancer[Title/Abstract]", "cancer[Title/Abstract]"),
    ('"cancer AND treatment"', "cancer AND treatment"),
    (
        '"cancer[Title/Abstract] AND immunotherapy"',
        "cancer[Title/Abstract] AND immunotherapy",
    ),
    (
        "cancer[Title/Abstract] AND immunotherapy",
        "cancer[Title/Abstract] AND immunotherapy",
    ),
    ('"Here is the query: cancer[Title/Abstract]"', "cancer[Title/Abstract]"),
    (
        '"The following query: (cancer OR tumor) AND treatment"',
        "(cancer OR tumor) AND treatment",
    ),
    ('"alpha [mesh] AND gamma"', "alpha [Mesh] AND gamma"),
    ("alpha [Mesh] AND gamma", "alpha [Mesh] AND gamma"),
    (
        '"cancer [Title/Abstract] AND treatment [Title/Abstract]"',
        "cancer [Title/Abstract] AND treatment [Title/Abstract]",
    ),
    (
        "cancer [Title/Abstract] AND treatment [Title/Abstract]",
        "cancer [Title/Abstract] AND treatment [Title/Abstract]",
    ),
    ("cancer [Mesh] AND treatment", "cancer [Mesh] AND treatment"),
    ('"cancer [MeSH] AND treatment"', "cancer [Mesh] AND treatment"),
    ('"cancer and treatment"', "cancer and treatment"),
    (
        '"Based on your question: cancer treatment"',
        "Based on your question: cancer treatment",
    ),
    ('"foo [bar]"[Title/Abstract]', '"foo "[bar]"[Title/Abstract]'),
    ('"one[T] AND "two[T', '"one"[T] AND "two"[T'),
    ("one[T] AND two[T", "one[T] AND two[T"),
    ('"" AND vaccin*[Title/Abstract]', '"" AND vaccin*[Title/Abstract]'),
    ('"foo[bar][Title/Abstract]', '"foo[bar]"[Title/Abstract]'),
    ("foo[bar][Title/Abstract]", "foo[bar][Title/Abstract]"),
    ('"a[b AND c[Title/Abstract]', '"a[b AND c"[Title/Abstract]'),
    ("a[b AND c[Title/Abstract]", "a[b AND c[Title/Abstract]"),
    (
        '(vaccine[Mesh] OR "alpha [Mesh] gamma"[Title/Abstract])',
        '(vaccine[Mesh] OR "alpha "[Mesh] gamma"[Title/Abstract])',
    ),
    (
        '(vaccine OR "alpha [Mesh] gamma"[Title/Abstract])',
        '(vaccine OR "alpha "[Mesh] gamma"[Title/Abstract])',
    ),
    (
        "cancer[Title/Abstract] AND treatment[Title/Abstract]",
        "cancer[Title/Abstract] AND treatment[Title/Abstract]",
    ),
    ("valid_phrases[", "valid_phrases["),
    ("orphan[", "orphan["),
    (
        'cancer[Title/Abstract] AND treatment[Title/Abstract]"',
        'cancer[Title/Abstract] AND treatment[Title/Abstract]"',
    ),
    ("wrapped_structured[", "wrapped_structured["),
    ("wrapped[", "wrapped["),
    ("retry_path[", "retry_path["),
    ("COV[", "COV["),
    ("[Mesh]", "[Mesh]"),
    ("[Mesh] ", "[Mesh]"),
    (
        "cancer[Mesh] AND treatment[Title/Abstract]",
        "cancer[Mesh] AND treatment[Title/Abstract]",
    ),
    (
        '"Review"[Publication Type] AND cancer',
        '"Review"[Publication Type] AND cancer',
    ),
    ("Here is the query: cancer[Title/Abstract]", "cancer[Title/Abstract]"),
    ("This query searches for: mRNA[Title/Abstract]", "mRNA[Title/Abstract]"),
    (
        "cancer[mesh] AND treatment[title/abstract]",
        "cancer[Mesh] AND treatment[Title/Abstract]",
    ),
    (
        "This query will find articles about vaccines. (mRNA[Title/Abstract] OR messenger[Title/Abstract]) AND vaccin*[Title/Abstract]. This approach uses wildcards for broader coverage and focuses on title and abstract fields. Additional explanation padding text to make it really long and exceed the threshold.",
        "(mRNA[Title/Abstract] OR messenger[Title/Abstract]) AND vaccin*[Title/Abstract]",
    ),
    (
        '"Based on"[tiab] AND evidence: review[pt]',
        '"Based on"[tiab] AND evidence: review[pt]',
    ),
    (
        'based on evidence[tiab] AND "2020/01/01":"2025/12/31"[dp]',
        'based on evidence[tiab] AND "2020/01/01":"2025/12/31"[dp]',
    ),
    (
        '"Here is the query: "mRNA vaccine"[tiab] AND elderly[tiab]"',
        '"mRNA vaccine"[tiab] AND elderly[tiab]',
    ),
    (
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND "vaccine efficacy".',
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND "vaccine efficacy".',
    ),
    (
        '"Vaccines"[Mesh] AND "booster dose"?',
        '"Vaccines"[Mesh] AND "booster dose"?',
    ),
    (
        '("Breast Neoplasms"/drug therapy[Mesh])',
        '("Breast Neoplasms"/drug therapy[Mesh])',
    ),
    ("Sample preview title: '", "Sample preview title: '"),
    ("...'", "...'"),
    (" [", "["),
    ('"mRNA vaccine efficacy elderly"', "mRNA vaccine efficacy elderly"),
    ('"mRNA vaccines"', "mRNA vaccines"),
    ('"Here is the query: "x"[Mesh] AND y[tiab]"', '"x"[Mesh] AND y[tiab]'),
    (
        '"Here is the query: (mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]"',
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
    ),
    (
        '"(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]"',
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
    ),
    (
        '"Vaccines"[Mesh] AND "elderly"[Title/Abstract]',
        '"Vaccines"[Mesh] AND "elderly"[Title/Abstract]',
    ),
    ('"COVID-19 vaccine myocarditis"', "COVID-19 vaccine myocarditis"),
    ('"long COVID treatment outcomes"', "long COVID treatment outcomes"),
    (
        'Here is the query: (mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
    ),
    (
        'Here\'s the optimized PubMed query: "mRNA vaccine"[Mesh] AND elderly[tiab]',
        '"mRNA vaccine"[Mesh] AND elderly[tiab]',
    ),
    (
        "Based on your question: (cancer[Mesh]) AND immunotherapy[tiab]",
        "Based on your question: (cancer[Mesh]) AND immunotherapy[tiab]",
    ),
    (
        "Based on recent literature, cancer[Mesh] AND immunotherapy[tiab]",
        "Based on recent literature, cancer[Mesh] AND immunotherapy[tiab]",
    ),
    (
        '"Based on your question, here is: cancer[Mesh]"',
        "Based on your question, here is: cancer[Mesh]",
    ),
    ('"Here is: mRNA vaccine"', "mRNA vaccine"),
    ('"Here is the PubMed query"', "Here is the PubMed query"),
    (
        '"Here\'s a query to find articles about vaccines..."',
        "Here's a query to find articles about vaccines...",
    ),
    ('"query: cancer[Mesh]"', "query: cancer[Mesh]"),
    ('"Query: cancer AND treatment"', "Query: cancer AND treatment"),
    (
        '"Search query: (influenza[tiab] OR flu[tiab]) AND treatment[tiab]"',
        "Search query: (influenza[tiab] OR flu[tiab]) AND treatment[tiab]",
    ),
    (
        '"PubMed query: mRNA vaccine elderly"',
        "PubMed query: mRNA vaccine elderly",
    ),
    (
        "`(mRNA[Title/Abstract]) AND vaccin*[Title/Abstract]`",
        "`(mRNA[Title/Abstract]) AND vaccin*[Title/Abstract]`",
    ),
    ('"mRNA[tiab] vaccine"', "mRNA[tiab] vaccine"),
    ('"cancer[Majr]"', "cancer[Majr]"),
    ('"cancer[MeSH Major Topic]"', "cancer[MeSH Major Topic]"),
    ('"cancer[sb]"', "cancer[sb]"),
    ('"Neoplasms/therapy[Mesh]"', "Neoplasms/therapy[Mesh]"),
    ('"cancer[TIAB]"', "cancer[TIAB]"),
    ('"cancer not mice"', "cancer not mice"),
    ('"breast cancer or ovarian cancer"', "breast cancer or ovarian cancer"),
    ('"and"', "and"),
    ('"Not a query"', "Not a query"),
    ('"cancer treatment[Title/Abstract]"', "cancer treatment[Title/Abstract]"),
    ('"messenger RNA"[Title/Abstract]', '"messenger RNA"[Title/Abstract]'),
    ("mRNA vaccine[Title/Abstract]", "mRNA vaccine[Title/Abstract]"),
    (
        '("heart attack"[tiab] OR "myocardial infarction"[Mesh]) AND aspirin[tiab]',
        '("heart attack"[tiab] OR "myocardial infarction"[Mesh]) AND aspirin[tiab]',
    ),
    (
        '"heart attack"[tiab] OR "myocardial infarction[Mesh]',
        '"heart attack"[tiab] OR "myocardial infarction"[Mesh]',
    ),
    (
        '"Vaccines"[MeSH] AND "Aged"[MeSH] AND efficacy[tiab]',
        '"Vaccines"[Mesh] AND "Aged"[Mesh] AND efficacy[tiab]',
    ),
    (
        '"Review"[Publication Type] AND cancer[mesh]',
        '"Review"[Publication Type] AND cancer[Mesh]',
    ),
    (
        '("Diabetes Mellitus, Type 2"[Mesh]) AND metformin[tiab]',
        '("Diabetes Mellitus, Type 2"[Mesh]) AND metformin[tiab]',
    ),
    (
        '"Alzheimer\'s disease"[tiab] AND amyloid[tiab]',
        '"Alzheimer\'s disease"[tiab] AND amyloid[tiab]',
    ),
    (
        "Alzheimer's disease[tiab] AND amyloid[tiab]",
        "Alzheimer's disease[tiab] AND amyloid[tiab]",
    ),
    ('"Crohn\'s disease"[Mesh]', '"Crohn\'s disease"[Mesh]'),
    (
        '"Parkinson\'s disease" AND "deep brain stimulation"',
        'Parkinson\'s disease" AND "deep brain stimulation',
    ),
    (
        '"COVID-19"[Mesh] AND "long COVID"[tiab]',
        '"COVID-19"[Mesh] AND "long COVID"[tiab]',
    ),
    ("'mRNA vaccine'[tiab]", "'mRNA vaccine'[tiab]"),
    ("“mRNA vaccine”[tiab] AND elderly", "“mRNA vaccine”[tiab] AND elderly"),
    ('"cancer[Mesh]" AND "treatment"', 'cancer[Mesh]" AND "treatment'),
    ('"\\"', "\\"),
    (
        '"Here is the query:\\n(cancer[Mesh]) AND therapy[tiab]"',
        "\\n(cancer[Mesh]) AND therapy[tiab]",
    ),
    ("Here is the query:\\ncancer[Mesh]", "\\ncancer[Mesh]"),
    ('"5" AND "10"', '5" AND "10'),
    ('"vaccine" AND "elderly"', 'vaccine" AND "elderly'),
    (
        '"CRISPR-Cas9 gene editing" AND "sickle cell"',
        'CRISPR-Cas9 gene editing" AND "sickle cell',
    ),
    (
        '"IL-6"[tiab] AND "rheumatoid arthritis"[Mesh]',
        '"IL-6"[tiab] AND "rheumatoid arthritis"[Mesh]',
    ),
    (
        "cancer[mesh] AND therapy[Title/abstract]",
        "cancer[Mesh] AND therapy[Title/Abstract]",
    ),
    (
        '"this query will find cancer[Mesh] AND therapy"',
        "this query will find cancer[Mesh] AND therapy",
    ),
    ('"The following PubMed query should work: cancer[tiab]"', "cancer[tiab]"),
    ("[Title/Abstract]", "[Title/Abstract]"),
    ("[Publication Type]", "[Publication Type]"),
    ('"[', '"['),
    ("[tiab]", "[tiab]"),
    ("[mesh]", "[Mesh]"),
    ('"PET AND "[18F]FDG uptake"[tiab]', '"PET AND "[18F]FDG uptake"[tiab]'),
    ('PET" AND "[18F]FDG uptake"[tiab]', 'PET" AND "[18F]FDG uptake"[tiab]'),
    ('"a OR "(good phrase)"', 'a OR "(good phrase)'),
    (
        '"vaccine AND "(heart attack)"[tiab]',
        '"vaccine AND "(heart attack)"[tiab]',
    ),
    ('"cancer OR ":"2025"[dp]', '"cancer OR ":"2025"[dp]'),
    ('"cancer OR ",stroke', '"cancer OR ",stroke'),
    (
        '"heart attack"[tiab] AND "stroke".',
        '"heart attack"[tiab] AND "stroke".',
    ),
    (
        '("heart attack"[tiab] OR "myocardial infarction"[tiab]) AND "aspirin".',
        '("heart attack"[tiab] OR "myocardial infarction"[tiab]) AND "aspirin".',
    ),
    ('"heart attack"*[tiab]', '"heart attack"*[tiab]'),
    ('"breast feed*"[tiab]', '"breast feed*"[tiab]'),
    ('"heart attack"[tiab].', '"heart attack"[tiab].'),
    ('"heart attack"; stroke', '"heart attack"; stroke'),
    ('"heart attack" ; stroke', '"heart attack" ; stroke'),
    ('"heart attack"\xa0AND stroke', '"heart attack"\xa0AND stroke'),
    ('"heart attack"\u200bAND stroke', '"heart attack"\u200bAND stroke'),
    ('"vaccine" AND "mRNA"\'', '"vaccine" AND "mRNA"\''),
    (
        "“messenger RNA”[Title/Abstract] AND vaccin*[tiab]",
        "“messenger RNA”[Title/Abstract] AND vaccin*[tiab]",
    ),
    ("‘messenger RNA’[tiab]", "‘messenger RNA’[tiab]"),
    ('"a""b"', 'a""b'),
    ('"x"[tiab]', '"x"[tiab]'),
    ('"hip pain"[tiab:~3]', '"hip pain"[tiab:~3]'),
    ('"vaccin*"', "vaccin*"),
    ('"heart attack"*', '"heart attack"*'),
    ('("heart attack")', '("heart attack")'),
    (
        '("heart attack" OR "cardiac arrest")',
        '("heart attack" OR "cardiac arrest")',
    ),
    ('NOT "heart attack"', 'NOT "heart attack"'),
    ('cancer NOT"heart attack"', 'cancer NOT"heart attack"'),
    ('cancer AND("heart attack")', 'cancer AND("heart attack")'),
    ('-"heart attack"', '-"heart attack"'),
    ('cancer/"heart attack"', 'cancer/"heart attack"'),
    ('["heart attack"]', '["heart attack"]'),
    ('cancer[tiab] AND "x"[ti]/"y"', 'cancer[tiab] AND "x"[ti]/"y"'),
    ('"" AND cancer', '"" AND cancer'),
    ('\\"heart attack\\"', '\\"heart attack\\"'),
    ('"2020/01/01"[dp]:"2025"[dp]', '"2020/01/01"[dp]:"2025"[dp]'),
    ('"2020":"2025"[dp]', '"2020":"2025"[dp]'),
    ("2020:2025[dp]", "2020:2025[dp]"),
    ('"Crohn\'s disease"[tiab]', '"Crohn\'s disease"[tiab]'),
    ('"Sjögren syndrome"[tiab]', '"Sjögren syndrome"[tiab]'),
    ('"heart\tattack"[tiab]', '"heart\tattack"[tiab]'),
    ('"heart attack"[tiab]AND cancer', '"heart attack"[tiab]AND cancer'),
    ('"heart attack",cancer', '"heart attack",cancer'),
    ('"heart attack";"stroke"', 'heart attack";"stroke'),
    ('"heart attack".', '"heart attack".'),
    ('"heart attack"?', '"heart attack"?'),
    ('"heart attack"!', '"heart attack"!'),
    ('"heart attack"&cancer', '"heart attack"&cancer'),
    ('"heart attack"|"stroke"', 'heart attack"|"stroke'),
    ('cancer "heart attack"', 'cancer "heart attack"'),
    ('"COVID-19"[tiab] AND "long-COVID"', 'COVID-19"[tiab] AND "long-COVID'),
    ('"long-COVID"-related', '"long-COVID"-related'),
    ('word"phrase here"[tiab]', 'word"phrase here"[tiab]'),
    ('"T-cell" AND "B-cell"', 'T-cell" AND "B-cell'),
    ('"a b" "c d" "e f"', 'a b" "c d" "e f'),
    ('"a b"[tiab] "c d"[tiab]', '"a b"[tiab] "c d"[tiab]'),
    ('"a [mesh] b"[tiab] AND x[mesh]', '"a "[Mesh] b"[tiab] AND x"[Mesh]'),
    (
        'x[mesh] AND "y [MESH]" AND z[MeSH]',
        'x[Mesh] AND "y "[Mesh]" AND z"[Mesh]',
    ),
    ('"a "b" c"', 'a "b" c'),
    ('""heart attack""', '"heart attack"'),
    ('"heart attack" "', 'heart attack" '),
    ('" heart attack"', " heart attack"),
    ('"heart attack "', "heart attack "),
    ('"heart attack"""[tiab]', '"heart attack"""[tiab]'),
    ('"smith j"[au] AND "smith j"[1au]', '"smith j"[au] AND "smith j"[1au]'),
    ('"cancer"[Mesh:NoExp]', '"cancer"[Mesh:NoExp]'),
    ('"cancer"[majr]', '"cancer"[majr]'),
    ('"cancer"{mesh}', '"cancer"{mesh}'),
    ('"cancer"<tiab>', '"cancer"<tiab>'),
    ('"cancer"~3', '"cancer"~3'),
    ('"cancer"\'', '"cancer"\''),
    ('(("heart attack"))', '(("heart attack"))'),
    ('"heart attack"))', '"heart attack"))'),
    ('"(heart attack)"', "(heart attack)"),
    (
        '"heart attack" AND (stroke OR "brain attack")',
        '"heart attack" AND (stroke OR "brain attack")',
    ),
    ('"x y"', "x y"),
    ('Crohn"s', 'Crohn"s'),
    ("[dp]", "[dp]"),
    ("[Title:~3]", "[Title:~3]"),
    ("“", "“"),
    ("”", "”"),
    ("'", "'"),
    ('"a', '"a'),
    ('a"', 'a"'),
    ('" ', ""),
    ('""a', '""a'),
    ('"a b" ', "a b"),
    ('a"b ', 'a"b'),
    ('"AND"', "AND"),
    ('"x"AND"y" ', 'x"AND"y'),
    ('"a[b]"[tiab] ', '"a"[b]"[tiab]'),
    ('"cancer [filter] therapy"', "cancer [filter] therapy"),
    ('"nature [so] review"', "nature [so] review"),
    ('"the [all] approach"', "the [all] approach"),
    ('"alpha [page] beta"', "alpha [page] beta"),
    ('"x [is] y"', "x [is] y"),
    ('"hello [word]"', "hello [word]"),
    ('"a [ed] b"', "a [ed] b"),
    ('"Bob [Ta]"', "Bob [Ta]"),
    ('"p53 [mh] mice"', "p53 [mh] mice"),
    ('"Here is: cancer"', "cancer"),
    ('"cancer" AND "treatment" AND "x"', 'cancer" AND "treatment" AND "x'),
    ('"smoking cessation" [sb]', '"smoking cessation" [sb]'),
    ('"cancer[tiab]"', "cancer[tiab]"),
    ('"" AND ""', '" AND "'),
    ('cancer "" AND x', 'cancer "" AND x'),
    ('"alpha [lang] x"', "alpha [lang] x"),
    ('"a [pt]"', "a [pt]"),
    ('"a [Mesh] b" AND "c [mesh] d"', 'a [Mesh] b" AND "c [Mesh] d'),
    ('"a [Mesh] b" AND x[Mesh]', '"a "[Mesh] b" AND x"[Mesh]'),
    ('"a ; b"[Mesh]', '"a ; b"[Mesh]'),
    (
        "Here is the query: cancer[tiab] AND treatment[tiab]",
        "cancer[tiab] AND treatment[tiab]",
    ),
    (
        'Here\'s the optimized PubMed query: (mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
        '(mRNA[Title/Abstract] OR "messenger RNA"[Title/Abstract]) AND vaccin*[Title/Abstract]',
    ),
    (
        'Here is the query:"heart attack"[tiab] AND aspirin[tiab]',
        '"heart attack"[tiab] AND aspirin[tiab]',
    ),
    ("Here is the query:cancer[tiab]", "cancer[tiab]"),
    (
        'Here is a "PubMed" query: cancer[tiab] AND therapy[tiab]',
        "cancer[tiab] AND therapy[tiab]",
    ),
    (
        'Here is the PubMed query for "heart failure": "heart failure"[Mesh] AND diuretics[tiab]',
        '"heart failure"[Mesh] AND diuretics[tiab]',
    ),
    (
        "Here's the query (using [Title/Abstract] tags): cancer[tiab]",
        "cancer[tiab]",
    ),
    ("Here is the query (10:30 rule): cancer[tiab]", "30 rule): cancer[tiab]"),
    (
        "Based on your question: cancer[tiab] AND therapy[tiab]",
        "Based on your question: cancer[tiab] AND therapy[tiab]",
    ),
    (
        "Based on the question, here is the query: cancer[tiab] AND therapy[tiab]",
        "Based on the question, here is the query: cancer[tiab] AND therapy[tiab]",
    ),
    (
        "Based on evidence[tiab] AND outcome[tiab]",
        "Based on evidence[tiab] AND outcome[tiab]",
    ),
    (
        'Based on "real world" data: cancer[tiab]',
        'Based on "real world" data: cancer[tiab]',
    ),
    (
        'Here\'s the query: "hip pain"[Title:~3] AND arthroplasty[tiab]',
        '"hip pain"[Title:~3] AND arthroplasty[tiab]',
    ),
    ('The following query: "hip pain"[Title:~3]', '"hip pain"[Title:~3]'),
    ('The following "query" is: cancer[tiab]', "cancer[tiab]"),
    ('Here is the "best" query: cancer[tiab]', "cancer[tiab]"),
    (
        "Here is the query: 2020:2025[dp] AND cancer[tiab]",
        "2020:2025[dp] AND cancer[tiab]",
    ),
    ("Here is the query 2:cancer[tiab]", "cancer[tiab]"),
    (
        '"Here is the query: cancer[tiab] AND therapy[tiab]"',
        "cancer[tiab] AND therapy[tiab]",
    ),
    ('"Here\'s the query": cancer[tiab]', '"Here\'s the query": cancer[tiab]'),
    (
        "Here's the query - cancer[tiab] AND therapy[tiab]",
        "Here's the query - cancer[tiab] AND therapy[tiab]",
    ),
    ("Here is the query —  cancer[tiab]", "Here is the query —  cancer[tiab]"),
    ("Here is my query; cancer[tiab]", "Here is my query; cancer[tiab]"),
    (
        'Here\'s a PubMed query for COVID-19: "COVID-19"[Mesh] AND vaccin*[tiab]',
        '"COVID-19"[Mesh] AND vaccin*[tiab]',
    ),
    (
        'Here is the query for "long COVID: a review": cancer[tiab]',
        'a review": cancer"[tiab]',
    ),
    (
        "This query searches for: cancer[tiab] AND therapy[tiab]",
        "cancer[tiab] AND therapy[tiab]",
    ),
    ('This query: "x y"', '"x y"'),
    (
        "The following search string is recommended:  (cancer[tiab] OR tumor[tiab])",
        "(cancer[tiab] OR tumor[tiab])",
    ),
    ('Here is the query for 5" fragments: cancer[tiab]', "cancer[tiab]"),
    ("Here is the query for 3' and 5\" UTR: cancer[tiab]", "cancer[tiab]"),
    ('""a b"[ti] AND "c d"[ti]"', '"a b"[ti] AND "c d"[ti]'),
    (
        '"(cancer OR "heart attack") AND aspirin"',
        '(cancer OR "heart attack") AND aspirin',
    ),
    ('"heart attack" AND "aspirin"', 'heart attack" AND "aspirin'),
    (
        '"aspirin" AND "heart attack"[tiab]"',
        'aspirin" AND "heart attack"[tiab]',
    ),
    ('"Here\'s the query: cancer[tiab] AND "x y""', 'cancer[tiab] AND "x y"'),
    (
        'Based on your question, here is the "optimized" query: cancer[tiab]',
        'Based on your question, here is the "optimized" query: cancer[tiab]',
    ),
    ('"Here is the query:"x"[Mesh] AND y[tiab]"', '"x"[Mesh] AND y[tiab]'),
    (
        "based on evidence[tiab] AND 2020:2025[dp]",
        "based on evidence[tiab] AND 2020:2025[dp]",
    ),
    (
        'Here is the query: "2020/01/01":"2025/12/31"[dp] AND cancer[tiab]',
        '"2020/01/01":"2025/12/31"[dp] AND cancer[tiab]',
    ),
    (
        '"messenger RNA" AND vaccin*[Title/Abstract]',
        '"messenger RNA" AND vaccin*[Title/Abstract]',
    ),
    (
        '"Review"[Publication Type] AND cancer[Title/Abstract]',
        '"Review"[Publication Type] AND cancer[Title/Abstract]',
    ),
    ('"last 1 month"p', '"last 1 month"p'),
    ('"last 3 years"p', '"last 3 years"p'),
    ('"last 5 years"p', '"last 5 years"p'),
    ('"last 12 months"p', '"last 12 months"p'),
    ("[Study Type: Meta-Analysis]", "[Study Type: Meta-Analysis]"),
    ("[Study Type:", "[Study Type:"),
    (
        '"cancer[Title/Abstract] AND treatment[Title/Abstract]"',
        "cancer[Title/Abstract] AND treatment[Title/Abstract]",
    ),
    ('"cancer[Title', '"cancer"[Title'),
    (
        '"Review"[publication type] AND cancer[title/abstract]',
        '"Review"[Publication Type] AND cancer[Title/Abstract]',
    ),
    ("[pdat]", "[pdat]"),
    ("[Free Full Text]", "[Free Full Text]"),
    ("[GER]", "[GER]"),
    ("cancer [mj]", "cancer [mj]"),
    ("nature [so]", "nature [so]"),
    ("0028-0836 [is]", "0028-0836 [is]"),
    ('x" AND "a [Mesh] b"', 'x" AND "a [Mesh] b"'),
    (
        '("heart attack"[tiab] OR MI[tiab]) AND "aspirin".',
        '("heart attack"[tiab] OR MI[tiab]) AND "aspirin".',
    ),
    (
        '("heart attack"OR"cardiac arrest")',
        '("heart attack"OR"cardiac arrest")',
    ),
    ('cancer[tiab] NOT"x y"', 'cancer[tiab] NOT"x y"'),
    ('cancer[tiab] -"x y"', 'cancer[tiab] -"x y"'),
    ('"x y"?', '"x y"?'),
    ('"x y";', '"x y";'),
    ('"Breast Neoplasms"/therapy[Mesh]', '"Breast Neoplasms"/therapy[Mesh]'),
    ('"a b"."[18F]FDG uptake"', 'a b"."[18F]FDG uptake'),
    ('"x"[Mesh] AND y[tiab]', '"x"[Mesh] AND y[tiab]'),
    ('"Here is the query: "heart attack""', '"heart attack"'),
    ('"heart attack"', "heart attack"),
    ('""cancer[Mesh] AND treatment"', '"cancer"[Mesh] AND treatment'),
    ("cancer[Mesh] AND treatment", "cancer[Mesh] AND treatment"),
    ('x" AND "a [Mesh] b"[Mesh]', 'x" AND "a [Mesh] b"[Mesh]'),
    ('"is issue', '"is issue'),
    ('"issue', '"issue'),
    (
        '"cancer[tiab] AND "heart attack"[tiab]"',
        'cancer[tiab] AND "heart attack"[tiab]',
    ),
    (
        '""heart attack"[tiab] AND aspirin[tiab]"',
        '"heart attack"[tiab] AND aspirin[tiab]',
    ),
    (
        '"(cancer OR tumor) AND "immune checkpoint"[tiab]"',
        '(cancer OR tumor) AND "immune checkpoint"[tiab]',
    ),
    ('"aspirin[tiab] AND "heart attack""', 'aspirin[tiab] AND "heart attack"'),
    ('"cancer treatment"', "cancer treatment"),
    ('"research and development"', "research and development"),
    ('"salt and pepper noise"', "salt and pepper noise"),
    ('"not otherwise specified"', "not otherwise specified"),
    ('"Not Otherwise Specified"', "Not Otherwise Specified"),
    ('"or"', "or"),
    ('"cancer[ti:~2]"', "cancer[ti:~2]"),
    ('"cancer[tiab:~0] AND x"', "cancer[tiab:~0] AND x"),
    ('"cancer [majr]"', "cancer [majr]"),
    ('"cancer [mesh:noexp]"', "cancer [mesh:noexp]"),
    ('"cancer[Filter]"', "cancer[Filter]"),
    ('"humans[mh] NOT animals[mh]"', "humans[mh] NOT animals[mh]"),
    ('"vaccine efficacy"[tiab]', '"vaccine efficacy"[tiab]'),
    ('"COVID-19 vaccine"', "COVID-19 vaccine"),
    ('"cancer*"', "cancer*"),
    ('"cancer treatment[x]"', "cancer treatment[x]"),
    ('"alpha [is] beta"', "alpha [is] beta"),
    ('"vitamin D [so] 2020"', "vitamin D [so] 2020"),
    ('"is"', "is"),
    ('"cancer treatment" AND x"', 'cancer treatment" AND x'),
    ('x AND "cancer treatment" "', 'x AND "cancer treatment" "'),
    ('"cancer, treatment"', "cancer, treatment"),
    ('"Breast Neoplasms/therapy[Mesh]"', "Breast Neoplasms/therapy[Mesh]"),
    (
        '"cancer AND (treatment OR therapy)"',
        "cancer AND (treatment OR therapy)",
    ),
    ('"cancer NEAR treatment"', "cancer NEAR treatment"),
    ('heart attack"', 'heart attack"'),
    (
        '("heart attack" OR "myocardial infarction") AND aspirin[tiab]',
        '("heart attack" OR "myocardial infarction") AND aspirin[tiab]',
    ),
    (
        '"Here\'s the query: "heart attack" AND aspirin"',
        '"heart attack" AND aspirin',
    ),
    (
        'Here\'s the query: "heart attack" AND aspirin',
        '"heart attack" AND aspirin',
    ),
    ('"COVID-19" AND "long covid"', 'COVID-19" AND "long covid'),
    ("“heart attack” AND aspirin", "“heart attack” AND aspirin"),
    (
        '"heart attack"[tiab] AND "it\'s complicated"',
        'heart attack"[tiab] AND "it\'s complicated',
    ),
    (
        '"type 2 diabetes"[Mesh] AND (metformin OR "SGLT2 inhibitors")',
        '"type 2 diabetes"[Mesh] AND (metformin OR "SGLT2 inhibitors")',
    ),
    ('"salt and pepper"', "salt and pepper"),
    ('"not otherwise specified"[tiab]', '"not otherwise specified"[tiab]'),
    ("Query: cancer[tiab]", "Query: cancer[tiab]"),
    (
        "Based on the research question, here is the query: cancer[tiab]",
        "Based on the research question, here is the query: cancer[tiab]",
    ),
    (
        'Here is a PubMed query for "heart attack": "heart attack"[tiab] AND aspirin',
        '"heart attack"[tiab] AND aspirin',
    ),
    ('"cancer"[tiab]', '"cancer"[tiab]'),
    ('"heart attack" [tiab]', '"heart attack" [tiab]'),
    (
        '"Here is the query: (cancer OR tumor) AND "x y""',
        '(cancer OR tumor) AND "x y"',
    ),
    ("The following: cancer[tiab]", "cancer[tiab]"),
    ('"B cell" AND "T-cell"', 'B cell" AND "T-cell'),
    ('"5\' UTR"[tiab]', '"5\' UTR"[tiab]'),
    ('"3"-UTR', '"3"-UTR'),
    (
        'Here is the query:"heart attack"[tiab] AND aspirin',
        '"heart attack"[tiab] AND aspirin',
    ),
    (
        'Here is the optimized query for "mRNA vaccines": (mRNA[tiab] OR "messenger RNA"[tiab]) AND vaccin*[tiab]',
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND vaccin*[tiab]',
    ),
    (
        "Here's the PubMed search query for 'heart attack': \"heart attack\"[tiab]",
        '"heart attack"[tiab]',
    ),
    ('"Here is the query:"x y"[tiab] AND z"', '"x y"[tiab] AND z'),
    ("Here is the query for 2020: cancer[tiab]", "cancer[tiab]"),
    ("Here is the query (version 2): cancer[tiab]", "cancer[tiab]"),
    (
        "Here is the query: cancer[tiab] AND 2020:2025[dp]",
        "cancer[tiab] AND 2020:2025[dp]",
    ),
    ("Here is the query [PubMed]: cancer[tiab]", "cancer[tiab]"),
    ('Here is "the" query: cancer[tiab]', "cancer[tiab]"),
    ('Here\'s the query you asked for: "covid-19"[tiab]', '"covid-19"[tiab]'),
    (
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND vaccin*[tiab]',
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND vaccin*[tiab]',
    ),
    ('"heart attack"[tiab] AND aspirin', '"heart attack"[tiab] AND aspirin'),
    ('"x y"[tiab] AND z', '"x y"[tiab] AND z'),
    ("cancer[tiab]", "cancer[tiab]"),
    (
        'Here is the query for 5" fragments: "bone graft"[tiab]',
        '"bone graft"[tiab]',
    ),
    ('"bone graft"[tiab]', '"bone graft"[tiab]'),
    ("Here is query 1: cancer[tiab]", "cancer[tiab]"),
    (
        "Here is the query: Here is the query: cancer[tiab]",
        "Here is the query: cancer[tiab]",
    ),
    ('("heart attack"or"mi")', '("heart attack"or"mi")'),
    ('("heart attack"Or"mi")', '("heart attack"Or"mi")'),
    ('"heart attack"and stroke', '"heart attack"and stroke'),
    ('"heart attack"And stroke', '"heart attack"And stroke'),
    ('cancer[tiab] not"x y"', 'cancer[tiab] not"x y"'),
    ('cancer[tiab] Not"x y"', 'cancer[tiab] Not"x y"'),
    ('"x y"order', '"x y"order'),
    ('"x y" order', '"x y" order'),
    ('"x y"ANDROID', '"x y"ANDROID'),
    ('"x y" ANDROID', '"x y" ANDROID'),
    ('"x y"notch', '"x y"notch'),
    ('"x y" notch', '"x y" notch'),
    ('color"x y"', 'color"x y"'),
    ('cannot"x y"', 'cannot"x y"'),
    ('brand"x y"', 'brand"x y"'),
    (
        '("heart attack” OR "myocardial infarction”) AND aspirin',
        '("heart attack” OR "myocardial infarction”) AND aspirin',
    ),
    (
        '("heart attack" OR "myocardial infarction") AND aspirin',
        '("heart attack" OR "myocardial infarction") AND aspirin',
    ),
    (
        "“heart attack”[tiab] AND „myocardial infarction“[tiab]",
        "“heart attack”[tiab] AND „myocardial infarction“[tiab]",
    ),
    (
        '"heart attack"[tiab] AND "myocardial infarction"[tiab]',
        '"heart attack"[tiab] AND "myocardial infarction"[tiab]',
    ),
    (
        "«chest pain»[tiab] OR ″angina″[tiab] OR ‟x y‟ OR "a b"",
        "«chest pain»[tiab] OR ″angina″[tiab] OR ‟x y‟ OR "a b"",
    ),
    (
        '"chest pain"[tiab] OR "angina"[tiab] OR "x y" OR "a b"',
        'chest pain"[tiab] OR "angina"[tiab] OR "x y" OR "a b',
    ),
    (
        "“Crohn’s disease”[tiab] AND Alzheimer's[tiab]",
        "“Crohn’s disease”[tiab] AND Alzheimer's[tiab]",
    ),
    (
        '"Crohn’s disease"[tiab] AND Alzheimer\'s[tiab]',
        '"Crohn’s disease"[tiab] AND Alzheimer\'s[tiab]',
    ),
    ("“cancer[Mesh] AND treatment”", "“cancer[Mesh] AND treatment”"),
    ('" heart attack" AND stroke', '" heart attack" AND stroke'),
    ('"heart attack" AND stroke', '"heart attack" AND stroke'),
    ('"heart attack " AND stroke', '"heart attack " AND stroke'),
    ('(" heart attack ")', '(" heart attack ")'),
    ('"type 2"diabetes', '"type 2"diabetes'),
    ('"type 2" diabetes', '"type 2" diabetes'),
    ('"Crohn"s disease"', 'Crohn"s disease'),
    ('"Crohn s disease"', "Crohn s disease"),
    (
        '"carcinoma not otherwise specified"',
        "carcinoma not otherwise specified",
    ),
    ('"cancer or tumour"', "cancer or tumour"),
    ('"cancer NOT mice"', "cancer NOT mice"),
    ('"cancer And treatment"', "cancer And treatment"),
    ('"a b"AND"c d"', 'a b"AND"c d'),
    ('"x"OR(y OR z)', '"x"OR(y OR z)'),
    ('"heart attack"Andrew', '"heart attack"Andrew'),
    ('"a"NOTCH1', '"a"NOTCH1'),
    ('"term"orange', '"term"orange'),
    ('"term"anderson', '"term"anderson'),
    ('"a"AND2', '"a"AND2'),
    ('"heart attack"AND"stroke"', 'heart attack"AND"stroke'),
    ('("a b"OR"c d")AND e', '("a b"OR"c d")AND e'),
    ('"x"or"y"', 'x"or"y'),
    (
        '"Crohn\'s disease"[Mesh] AND therapy',
        '"Crohn\'s disease"[Mesh] AND therapy',
    ),
    (
        '"Alzheimer\'s disease"[tiab] OR "Parkinson\'s"[tiab]',
        '"Alzheimer\'s disease"[tiab] OR "Parkinson\'s"[tiab]',
    ),
    (
        '((("a b"[tiab] OR "c d"[tiab]) AND ("e f"[Mesh])) NOT "g h"[pt])',
        '((("a b"[tiab] OR "c d"[tiab]) AND ("e f"[Mesh])) NOT "g h"[pt])',
    ),
    (
        '"Smith J"[Author] AND "cancer"[tiab]',
        '"Smith J"[Author] AND "cancer"[tiab]',
    ),
    ('"2020/01/01"[dp] : "2024"[dp]', '"2020/01/01"[dp] : "2024"[dp]'),
    ('"2020/01/01"[dp]:"2024/12/31"[dp]', '"2020/01/01"[dp]:"2024/12/31"[dp]'),
    (
        '("2020"[dp] : "2024"[dp]) AND asthma',
        '("2020"[dp] : "2024"[dp]) AND asthma',
    ),
    ('"heart attack*"[tiab]', '"heart attack*"[tiab]'),
    ('"a b"[tiab]', '"a b"[tiab]'),
    ('"a b"*[tiab]', '"a b"*[tiab]'),
    (
        '\\"heart attack\\"[tiab] AND aspirin',
        '\\"heart attack\\"[tiab] AND aspirin',
    ),
    (
        '`"heart attack"[tiab] AND aspirin`',
        '`"heart attack"[tiab] AND aspirin`',
    ),
    ('```"heart attack"[tiab]```', '```"heart attack"[tiab]```'),
    ('"heart attack"[tiab] AND aspirin.', '"heart attack"[tiab] AND aspirin.'),
    ('aspirin AND "heart attack".', 'aspirin AND "heart attack".'),
    ('"  heart attack  "[tiab]', '"  heart attack  "[tiab]'),
    ("«heart attack»[tiab]", "«heart attack»[tiab]"),
    ("« heart attack »[tiab]", "« heart attack »[tiab]"),
    (
        "«\xa0infarctus du myocarde\xa0»[tiab]",
        "«\xa0infarctus du myocarde\xa0»[tiab]",
    ),
    ('lesion 2″ AND "melanoma"[tiab]', 'lesion 2″ AND "melanoma"[tiab]'),
    (
        "“heart attack”[tiab] AND “aspirin”",
        "“heart attack”[tiab] AND “aspirin”",
    ),
    ("„Herzinfarkt“[tiab]", "„Herzinfarkt“[tiab]"),
    (
        '"heart attack"[tiab] AND ″stroke″[tiab]',
        '"heart attack"[tiab] AND ″stroke″[tiab]',
    ),
    ('aspirin AND "heart attack"', 'aspirin AND "heart attack"'),
    ('"a b"[tiab] AND c', '"a b"[tiab] AND c'),
    ('"heart attack" Andrew', '"heart attack" Andrew'),
    ('"IL6"inhibitor', '"IL6"inhibitor'),
    ('"COVID-19"vaccine AND efficacy', '"COVID-19"vaccine AND efficacy'),
    (
        '"IL-6"[tiab]AND"tocilizumab"[tiab]',
        '"IL-6"[tiab]AND"tocilizumab"[tiab]',
    ),
    (
        '("a b"[tiab]OR"c d"[tiab])AND"e"[Mesh]',
        '("a b"[tiab]OR"c d"[tiab])AND"e"[Mesh]',
    ),
    (
        '"heart attack"[tiab]and"aspirin"[tiab]',
        '"heart attack"[tiab]and"aspirin"[tiab]',
    ),
    ('"heart attack"-related', '"heart attack"-related'),
    ('"heart attack"/"stroke"', 'heart attack"/"stroke'),
    ('"heart attack","stroke"', 'heart attack","stroke'),
    ('"Hodgkin"s lymphoma"[tiab]', '"Hodgkin"s lymphoma"[tiab]'),
    (
        '"Sjögren"s syndrome"[Mesh] AND therapy',
        '"Sjögren"s syndrome"[Mesh] AND therapy',
    ),
    ('"Parkinson’s disease"[tiab]', '"Parkinson’s disease"[tiab]'),
    ('"so-called «leaky gut»"[tiab]', '"so-called «leaky gut»"[tiab]'),
    ('"2″ lesion"[tiab]', '"2″ lesion"[tiab]'),
    (
        'lesions 2" to 5" in diameter AND melanoma',
        'lesions 2" to 5" in diameter AND melanoma',
    ),
    ('"heart attack " AND aspirin', '"heart attack " AND aspirin'),
    ('" heart attack"[tiab]', '" heart attack"[tiab]'),
    ('("heart attack ")', '("heart attack ")'),
    ('"heart attack "[tiab]', '"heart attack "[tiab]'),
    ('"heart attack"\t[tiab]', '"heart attack"\t[tiab]'),
    ('"" AND aspirin', '"" AND aspirin'),
    ('"heart attack"OR', '"heart attack"OR'),
    ('aspirin OR"heart attack"', 'aspirin OR"heart attack"'),
    ('aspirin OR"heart attack"[tiab]', 'aspirin OR"heart attack"[tiab]'),
    ('aspirin or"heart attack"', 'aspirin or"heart attack"'),
    ('aspirin and"heart attack"', 'aspirin and"heart attack"'),
    ('aspirin not"heart attack"', 'aspirin not"heart attack"'),
    ('aspirinAND"heart attack"', 'aspirinAND"heart attack"'),
    ('brand"heart attack"', 'brand"heart attack"'),
    ('Oregon"heart attack"', 'Oregon"heart attack"'),
    ('band"heart attack"', 'band"heart attack"'),
    ('knot"heart attack"', 'knot"heart attack"'),
    ('"mother"s day"', 'mother"s day'),
    ('mother"s day', 'mother"s day'),
    ('"heart attack"NOT"stroke"', 'heart attack"NOT"stroke'),
    ('"x y"Or"z w"', 'x y"Or"z w'),
    (
        '"heart attack"[tiab] AND «aspirin»[tiab]',
        '"heart attack"[tiab] AND «aspirin»[tiab]',
    ),
    ('"heart attack""', '"heart attack""'),
    (""heart attack"[tiab]", ""heart attack"[tiab]"),
    ('"heart attack"*"stroke"', 'heart attack"*"stroke'),
    ('"heart attack"(x)', '"heart attack"(x)'),
    (
        '**"heart attack"**[tiab] AND aspirin',
        '**"heart attack"**[tiab] AND aspirin',
    ),
    ('"vaccin*"[tiab]', '"vaccin*"[tiab]'),
    ('"COVID-19" OR vaccin*"[tiab]', '"COVID-19" OR vaccin*"[tiab]'),
    ('"the “obesity paradox”"[tiab]', '"the “obesity paradox”"[tiab]'),
    (
        '{"query": "\\"heart attack\\"[tiab] AND aspirin"}',
        '{"query": "\\"heart attack\\"[tiab] AND aspirin"}',
    ),
    (
        'Query: "heart attack"[tiab] AND aspirin',
        'Query: "heart attack"[tiab] AND aspirin',
    ),
    (
        '"heart attack"[tiab] "stroke"[tiab]',
        '"heart attack"[tiab] "stroke"[tiab]',
    ),
    ('(" heart attack" OR " stroke ")', '(" heart attack" OR " stroke ")'),
    ('"heart attack"[tiab]OR"MI"[tiab]', '"heart attack"[tiab]OR"MI"[tiab]'),
    ('"MI"[tiab]OR"stroke"', 'MI"[tiab]OR"stroke'),
    ('"Crohn"s"[tiab]', '"Crohn"s"[tiab]'),
    ('"Down syndrome"s', '"Down syndrome"s'),
    ('"Graves" disease"[Mesh]', '"Graves" disease"[Mesh]'),
    ('"Graves\' disease"[Mesh]', '"Graves\' disease"[Mesh]'),
    (
        '"Huntington"s disease"[Mesh] AND "gene therapy"[tiab]',
        '"Huntington"s disease"[Mesh] AND "gene therapy"[tiab]',
    ),
    ('"5 "-fluorouracil"', '5 "-fluorouracil'),
    ('"5\'-UTR"[tiab]', '"5\'-UTR"[tiab]'),
    ('"3"-UTR"', '3"-UTR'),
    ('"T-cell"s', '"T-cell"s'),
    ('"heart attack"s', '"heart attack"s'),
    ('"p53"-mediated', '"p53"-mediated'),
    ('"p53"mediated apoptosis', '"p53"mediated apoptosis'),
    ('"BRCA1"/"BRCA2"', 'BRCA1"/"BRCA2'),
    ('"miR-21"AND"cancer"', 'miR-21"AND"cancer'),
    ('"miR-21"and cancer', '"miR-21"and cancer'),
    ('"heart attack"andaspirin', '"heart attack"andaspirin'),
    ('"x"Not"y"', 'x"Not"y'),
    ('"x"Andy', '"x"Andy'),
    ('"x"Ornithine', '"x"Ornithine'),
    ('"x"Nottingham', '"x"Nottingham'),
    ('"PD-1"inhibitor', '"PD-1"inhibitor'),
    ('"anti-PD-1"therapy AND melanoma', '"anti-PD-1"therapy AND melanoma'),
    (
        '"PD-1"inhibitor AND "heart attack"[tiab]',
        '"PD-1"inhibitor AND "heart attack"[tiab]',
    ),
    (
        '"PD-1"inhibitor[tiab] OR nivolumab[tiab]',
        '"PD-1"inhibitor[tiab] OR nivolumab[tiab]',
    ),
    ('"PD-1"inhibitor*', '"PD-1"inhibitor*'),
    (
        "R1 punctuation-close (close only before space/[/)/]/end)",
        "R1 punctuation-close (close only before space/[/)/]/end)",
    ),
    (
        'str.maketrans(dict.fromkeys("“”„‟«»″"", \'"\'))',
        'str.maketrans(dict.fromkeys("“”„‟«»″"", \'"\'))',
    ),
    (
        'char if char != \'"\' else " " if index in spaced else ""',
        'char if char != \'"\' else " " if index in spaced else ""',
    ),
    ('char if char != \'"\' else ""', 'char if char != \'"\' else ""'),
    (
        '"Here is the query: cancer[Title/Abstract] AND treatment[Title/Abstract]"',
        "cancer[Title/Abstract] AND treatment[Title/Abstract]",
    ),
    (")];,.[", ")];,.["),
    ("“”„‟«»″"", "“”„‟«»″""),
    ('"last 10 years"[pdat]', '"last 10 years"[pdat]'),
    ('"last 2 years"[pdat]', '"last 2 years"[pdat]'),
    ('"last 6 months"[pdat]', '"last 6 months"[pdat]'),
    ('"last 1 year"[pdat]', '"last 1 year"[pdat]'),
    ('"last 5 years"[pdat]', '"last 5 years"[pdat]'),
    ("[Author]", "[Author]"),
    ("[Journal]", "[Journal]"),
    ('")]', '")]'),
    ('"last 3 years"[pdat]', '"last 3 years"[pdat]'),
    (".//ArticleId[@IdType='pmc']", ".//ArticleId[@IdType='pmc']"),
    ("[Study Type: ", "[Study Type:"),
    (" | [Free Full Text]", "| [Free Full Text]"),
    (
        "“Here is the query: cancer[tiab] AND treatment[tiab]”",
        "“Here is the query: cancer[tiab] AND treatment[tiab]”",
    ),
    (
        "Here is the query: “heart attack”[tiab] AND aspirin",
        "“heart attack”[tiab] AND aspirin",
    ),
    (
        "Here is the query:2020:2025[dp] AND covid[tiab]",
        "2020:2025[dp] AND covid[tiab]",
    ),
    ("Here is the query:12345678[pmid]", "12345678[pmid]"),
    (
        'Here is the query for "mRNA vaccines":"mRNA vaccine"[tiab]',
        '"mRNA vaccine"[tiab]',
    ),
    (
        'Here is the query for "COVID-19: long-term effects": covid[tiab] AND sequelae[tiab]',
        'long-term effects": covid[tiab] AND sequelae"[tiab]',
    ),
    ("Here is the query [note: tiab]: x[tiab]", "tiab]: x[tiab]"),
    ("Here is the query using [tiab:~2]: x[tiab]", "~2]: x[tiab]"),
    (
        '("heart attack[tiab] OR "myocardial infarction[tiab]) AND "aspirin[tiab]',
        '("heart attack"[tiab] OR "myocardial infarction"[tiab]) AND "aspirin"[tiab]',
    ),
    (
        '"signs and symptoms[tiab] AND "COVID-19[tiab]',
        '"signs and symptoms"[tiab] AND "COVID-19"[tiab]',
    ),
    (
        '"hand, foot and mouth disease[tiab]',
        '"hand, foot and mouth disease"[tiab]',
    ),
    (
        '"diagnostic and statistical manual[tiab] AND depression',
        '"diagnostic and statistical manual"[tiab] AND depression',
    ),
    (
        '"heart attack[tiab] AND "aspirin"[tiab]',
        '"heart attack"[tiab] AND "aspirin"[tiab]',
    ),
    (
        '("heart attack[Title/Abstract] OR "myocardial infarction[Title/Abstract]) AND ("aspirin[Mesh] OR "acetylsalicylic acid[Title/Abstract])',
        '("heart attack"[Title/Abstract] OR "myocardial infarction"[Title/Abstract]) AND ("aspirin"[Mesh] OR "acetylsalicylic acid"[Title/Abstract])',
    ),
    ('"Here is the query: "messenger RNA[tiab]"', '"messenger RNA"[tiab]'),
    (
        '"heart attack[tiab] OR "myocardial infarction[tiab]',
        '"heart attack"[tiab] OR "myocardial infarction"[tiab]',
    ),
    (
        '"heart attack[tiab] OR "myocardial infarction"[tiab]',
        '"heart attack"[tiab] OR "myocardial infarction"[tiab]',
    ),
    ('"bread and butter[tiab]', '"bread and butter"[tiab]'),
    (
        '"carcinoma not otherwise specified[tiab]',
        '"carcinoma not otherwise specified"[tiab]',
    ),
    ('("heart attack[tiab] OR MI[tiab])', '("heart attack[tiab] OR MI"[tiab])'),
    (
        '"heart attack[tiab] AND aspirin[tiab]',
        '"heart attack[tiab] AND aspirin"[tiab]',
    ),
    (
        '"type 2 diabetes[Mesh] AND "metformin"[tiab]',
        '"type 2 diabetes"[Mesh] AND "metformin"[tiab]',
    ),
    ('"PD-1"inhibitor AND "PD-L1"[tiab]', '"PD-1"inhibitor AND "PD-L1"[tiab]'),
    ('"PD-1"inhibitor OR "cancer"', 'PD-1"inhibitor OR "cancer'),
    (
        '5" catheter AND "heart failure"[tiab]',
        '5" catheter AND "heart failure"[tiab]',
    ),
    ('"COVID-19"vaccine[tiab]', '"COVID-19"vaccine[tiab]'),
    ('"COVID-19"[tiab] AND "long covid"', 'COVID-19"[tiab] AND "long covid'),
    ('"messenger RNA[tiab:~2]', '"messenger RNA"[tiab:~2]'),
    (
        '"Breast Neoplasms/drug therapy[Mesh]',
        '"Breast Neoplasms/drug therapy"[Mesh]',
    ),
    (
        '"heart attack"[tiab] AND "aspirin[tiab]',
        '"heart attack"[tiab] AND "aspirin"[tiab]',
    ),
    ('"IL-6"/"IL-10" ratio', '"IL-6"/"IL-10" ratio'),
    ('"Smith J[au]', '"Smith J"[au]'),
    ('"T cell"exhaustion AND "PD-1"', 'T cell"exhaustion AND "PD-1'),
    ("'heart attack'[tiab]", "'heart attack'[tiab]"),
    ('"heart attack"[tiab]AND aspirin', '"heart attack"[tiab]AND aspirin'),
    ('"Crohn and colitis"', "Crohn and colitis"),
    ('"Johnson and Johnson"[ad]', '"Johnson and Johnson"[ad]'),
    ('"rock and roll[tiab]', '"rock and roll"[tiab]'),
    ('"cancer or tumour[tiab]', '"cancer or tumour"[tiab]'),
    ('"vitamin D (25-OH) levels[tiab]', '"vitamin D (25-OH) levels"[tiab]'),
    (
        "based on evidence AND 2020/01/01[dp]:2025/01/01[dp]",
        "based on evidence AND 2020/01/01[dp]:2025/01/01[dp]",
    ),
    ('"cancer [foo] AND treatment"', "cancer [foo] AND treatment"),
    ('"Here is the query: cancer"', "cancer"),
    ('"x"[tiab] AND "y z[tiab]', '"x"[tiab] AND "y z"[tiab]'),
    ('"x y[tiab]]', '"x y"[tiab]]'),
    ('"a b [Mesh]', '"a b "[Mesh]'),
    ('"a b [Mesh] AND (x OR y)', '"a b "[Mesh] AND (x OR y)'),
    (
        '"Type 2 diabetes"[Mesh] AND "insulin resistance[tiab] OR "obesity"[Mesh]',
        '"Type 2 diabetes"[Mesh] AND "insulin resistance"[tiab] OR "obesity"[Mesh]',
    ),
    ('(a OR b) AND "c d[tiab]', '(a OR b) AND "c d"[tiab]'),
    ('"c d[tiab] AND (a OR b)', '"c d"[tiab] AND (a OR b)'),
    ('"c d" AND "e f[tiab] AND (a OR b)', '"c d" AND "e f"[tiab] AND (a OR b)'),
    ('Here is the query: "a b[tiab]', '"a b"[tiab]'),
    ('Here is the query: "a b[tiab] AND c', '"a b"[tiab] AND c'),
    ('here is the query: 5" x: "a b"[tiab]', '5" x: "a b"[tiab]'),
    ('"smith j[au] AND "doe a[au]', '"smith j"[au] AND "doe a"[au]'),
    ('"x y"[tiab] "z', '"x y"[tiab] "z'),
    ('"a b"', "a b"),
    ("x[tiab]", "x[tiab]"),
    ('"c d"', "c d"),
    ("[ti]AND", "[ti]AND"),
    ("'s", "'s"),
    (
        '"mRNA vaccine"[Mesh] AND "messenger RNA"[Title/Abstract]',
        '"mRNA vaccine"[Mesh] AND "messenger RNA"[Title/Abstract]',
    ),
    ("covid[tiab] AND sequelae[tiab]", "covid[tiab] AND sequelae[tiab]"),
    ("12345678[pmid]", "12345678[pmid]"),
    ("Here is query 2:cancer[tiab]", "cancer[tiab]"),
    ("cancer[tiab] AND treatment[tiab]", "cancer[tiab] AND treatment[tiab]"),
    ("Here’s the query: cancer[tiab]", "Here’s the query: cancer[tiab]"),
    (
        '("mRNA vaccine"[Mesh] OR "messenger RNA[tiab])',
        '("mRNA vaccine"[Mesh] OR "messenger RNA"[tiab])',
    ),
    (
        '("mRNA vaccine"[Mesh] OR "messenger RNA"[tiab])',
        '("mRNA vaccine"[Mesh] OR "messenger RNA"[tiab])',
    ),
    ('"messenger RNA [tiab]', '"messenger RNA "[tiab]'),
    ('"messenger RNA"[tiab]', '"messenger RNA"[tiab]'),
    ('"a[b and c[tiab]', '"a[b and c"[tiab]'),
    ("a[b and c[tiab]", "a[b and c[tiab]"),
    ('"a (b c[tiab]', '"a (b c"[tiab]'),
    ("a (b c[tiab]", "a (b c[tiab]"),
    ('"one[tiab] AND "two[tiab]', '"one"[tiab] AND "two"[tiab]'),
    ('one[tiab] AND "two"[tiab]', 'one[tiab] AND "two"[tiab]'),
    ('"PD-1"inhibitor AND melanoma', '"PD-1"inhibitor AND melanoma'),
    ('"PD-1" inhibitor AND melanoma', '"PD-1" inhibitor AND melanoma'),
    ('"COVID-19"vaccine', '"COVID-19"vaccine'),
    ('"COVID-19" vaccine', '"COVID-19" vaccine'),
    ('"p53"mediated', '"p53"mediated'),
    ('"p53" mediated', '"p53" mediated'),
    (
        "(“PD-1”inhibitor[tiab] OR pembrolizumab[tiab])",
        "(“PD-1”inhibitor[tiab] OR pembrolizumab[tiab])",
    ),
    (
        '("PD-1" inhibitor[tiab] OR pembrolizumab[tiab])',
        '("PD-1" inhibitor[tiab] OR pembrolizumab[tiab])',
    ),
    (
        '("PD-1"inhibitor[tiab] OR "PD-L1"blocker[tiab])',
        '("PD-1"inhibitor[tiab] OR "PD-L1"blocker[tiab])',
    ),
    (
        '("PD-1" inhibitor[tiab] OR "PD-L1" blocker[tiab])',
        '("PD-1" inhibitor[tiab] OR "PD-L1" blocker[tiab])',
    ),
    ('" a', '" a'),
    ('a"b', 'a"b'),
    ('"a[tiab] ', '"a"[tiab]'),
    ('"a b[foo] ', '"a b"[foo]'),
    ("[x", "[x"),
    ('"a AND ', '"a AND'),
    ('("a b"[tiab] OR "c"d) ', '("a b"[tiab] OR "c"d)'),
    ('"a":', '"a":'),
    ("x[a:", "x[a:"),
    ('"x', '"x'),
    ("[x]", "[x]"),
    ('"a[b AND c[tiab]', '"a[b AND c"[tiab]'),
    ('"a b[tiab] AND c', '"a b"[tiab] AND c'),
    ('x AND "a b[tiab]', 'x AND "a b"[tiab]'),
    ('"a b[tiab]) AND y', '"a b"[tiab]) AND y'),
    ('"a b (c)[tiab]', '"a b (c)"[tiab]'),
    ('("a b[tiab])', '("a b"[tiab])'),
    ('"a b" AND "c d[tiab]', '"a b" AND "c d"[tiab]'),
    ('"a not b[tiab]', '"a not b"[tiab]'),
    ('"cannot x[tiab]', '"cannot x"[tiab]'),
    ('"a b[foo] c[tiab]', '"a b[foo] c"[tiab]'),
    ('"a b[Title/Abstract:~3]', '"a b"[Title/Abstract:~3]'),
    ('("a b"or"c d")', '("a b"or"c d")'),
    ('"a b"and"c"', 'a b"and"c'),
    ('"a"OR"b"', 'a"OR"b'),
    ('"a b"NOT"c"', 'a b"NOT"c'),
    ('"a b" ,"c"', 'a b" ,"c'),
    ('"it\'s"[tiab]', '"it\'s"[tiab]'),
    ("“a b”", "“a b”"),
    ('“a b"', '“a b"'),
    ('"2[18F]FDG uptake"[tiab]', '"2"[18F]FDG uptake"[tiab]'),
    ('"2[18F]FDG uptake[tiab]', '"2[18F]FDG uptake"[tiab]'),
    ('"a b[tiab] c[tiab]', '"a b[tiab] c"[tiab]'),
    ('"a. b[tiab]', '"a. b"[tiab]'),
    ('"2020/01/01":"2025/12/31"', '2020/01/01":"2025/12/31'),
    ('for "mRNA vaccines": x', 'for "mRNA vaccines": x'),
    ('query:"heart attack"', 'query:"heart attack"'),
    ('"a":"b"', 'a":"b'),
    ('[x]"', '[x]"'),
    ('"(', '"('),
    ('a" ', 'a"'),
    ('"a"b ', '"a"b'),
    ('"2020":', '"2020":'),
    ('"a b"[tiab] AND "c', '"a b"[tiab] AND "c'),
    (" [x]", "[x]"),
    ("[foo] ", "[foo]"),
    ('x"y', 'x"y'),
    (")];,[", ")];,["),
    ('"Crohn"s disease"[tiab]', '"Crohn"s disease"[tiab]'),
    (
        '("heart attack[tiab] OR "myocardial infarction[tiab]) AND aspirin[tiab]',
        '("heart attack"[tiab] OR "myocardial infarction[tiab]) AND aspirin"[tiab]',
    ),
    (
        '"heart attack[Title/Abstract] OR "myocardial infarction[Title/Abstract]',
        '"heart attack"[Title/Abstract] OR "myocardial infarction"[Title/Abstract]',
    ),
    (
        '"signs and symptoms[tiab] AND fever[tiab]',
        '"signs and symptoms[tiab] AND fever"[tiab]',
    ),
    (
        '"diagnosis and management"[tiab] AND "heart failure[tiab]',
        '"diagnosis and management"[tiab] AND "heart failure"[tiab]',
    ),
    (
        '"heart failure[tiab] AND "diagnosis and management"[tiab]',
        '"heart failure"[tiab] AND "diagnosis and management"[tiab]',
    ),
    ('"Vaccines[Mesh:NoExp]', '"Vaccines"[Mesh:NoExp]'),
    (
        '"Vaccines[Mesh:NoExp] AND covid[tiab]',
        '"Vaccines[Mesh:NoExp] AND covid"[tiab]',
    ),
    ('"T-cell[tiab] AND cancer[tiab]', '"T-cell[tiab] AND cancer"[tiab]'),
    ('"T-cell/B-cell interaction[tiab]', '"T-cell/B-cell interaction"[tiab]'),
    ('"vaccin*[tiab]', '"vaccin*"[tiab]'),
    (
        '"mRNA vaccin*[tiab] AND covid[tiab]',
        '"mRNA vaccin*[tiab] AND covid"[tiab]',
    ),
    (
        '"messenger RNA[Title/Abstract] AND vaccin*[Title/Abstract]',
        '"messenger RNA[Title/Abstract] AND vaccin*"[Title/Abstract]',
    ),
    (
        '(mRNA[Title/Abstract] OR "messenger RNA[Title/Abstract]) AND vaccin*[Title/Abstract]',
        '(mRNA[Title/Abstract] OR "messenger RNA[Title/Abstract]) AND vaccin*"[Title/Abstract]',
    ),
    (
        '"COVID-19 vaccines"[Mesh] AND "messenger RNA[tiab]',
        '"COVID-19 vaccines"[Mesh] AND "messenger RNA"[tiab]',
    ),
    ('"2[18F]FDG PET[tiab]', '"2[18F]FDG PET"[tiab]'),
    (
        '"Vaccines[Mesh] AND "influenza[tiab]',
        '"Vaccines"[Mesh] AND "influenza"[tiab]',
    ),
    ('"Vaccines[Mesh] OR vaccin*[tiab]', '"Vaccines[Mesh] OR vaccin*"[tiab]'),
    (
        '"type 2 diabetes[Mesh] AND (metformin[tiab] OR insulin[tiab])',
        '"type 2 diabetes[Mesh] AND (metformin[tiab] OR insulin"[tiab])',
    ),
    (
        '"PD-1"inhibitor[tiab] AND "lung cancer"[tiab]',
        '"PD-1"inhibitor[tiab] AND "lung cancer"[tiab]',
    ),
    (
        '"PD-1"inhibitor AND "non-small cell"[tiab]',
        '"PD-1"inhibitor AND "non-small cell"[tiab]',
    ),
    (
        '"PD-1"inhibitors[tiab] OR "PD-L1"[tiab]',
        '"PD-1"inhibitors[tiab] OR "PD-L1"[tiab]',
    ),
    ('Crohn"s disease[tiab]', 'Crohn"s disease"[tiab]'),
    ('5" catheter[tiab]', '5" catheter"[tiab]'),
    ("\"Crohn's disease[tiab]", '"Crohn\'s disease"[tiab]'),
    (
        '"Alzheimer\'s disease[Mesh] AND "amyloid beta"[tiab]',
        '"Alzheimer\'s disease"[Mesh] AND "amyloid beta"[tiab]',
    ),
    ('"Alzheimer"s disease[Mesh]', '"Alzheimer"s disease[Mesh]'),
    (
        '("signs and symptoms[tiab] OR "clinical presentation"[tiab]) AND covid[tiab]',
        '("signs and symptoms"[tiab] OR "clinical presentation"[tiab]) AND covid[tiab]',
    ),
    (
        '("heart failure[tiab] OR "cardiac failure"[tiab]) AND "SGLT2 inhibitors"[Mesh]',
        '("heart failure"[tiab] OR "cardiac failure"[tiab]) AND "SGLT2 inhibitors"[Mesh]',
    ),
    (
        '("messenger RNA[Title/Abstract] OR mRNA[Title/Abstract]) AND "COVID-19"[Mesh]',
        '("messenger RNA[Title/Abstract] OR mRNA"[Title/Abstract]) AND "COVID-19"[Mesh]',
    ),
    (
        '"Alzheimer Disease[Mesh] AND ("amyloid beta"[tiab] OR tau[tiab])',
        '"Alzheimer Disease"[Mesh] AND ("amyloid beta"[tiab] OR tau[tiab])',
    ),
    (
        '"heart failure[tiab] AND "SGLT2[tiab]',
        '"heart failure"[tiab] AND "SGLT2"[tiab]',
    ),
    (
        '"Diabetes Mellitus, Type 2[Mesh] AND "metformin"[tiab]',
        '"Diabetes Mellitus, Type 2"[Mesh] AND "metformin"[tiab]',
    ),
    ('"Diabetes Mellitus, Type 2[Mesh]', '"Diabetes Mellitus, Type 2"[Mesh]'),
    (
        '"Diabetes Mellitus, Type 2[Mesh] AND metformin[tiab]',
        '"Diabetes Mellitus, Type 2[Mesh] AND metformin"[tiab]',
    ),
    (
        '(mRNA[tiab] OR "messenger RNA[tiab]) AND "vaccine efficacy"[tiab]',
        '(mRNA[tiab] OR "messenger RNA"[tiab]) AND "vaccine efficacy"[tiab]',
    ),
    (
        '"heart attack"[tiab] OR "myocardial infarction[tiab] OR "acute coronary syndrome"[tiab]',
        '"heart attack"[tiab] OR "myocardial infarction"[tiab] OR "acute coronary syndrome"[tiab]',
    ),
    (
        '"PD-1"inhibitor[tiab] AND "non-small cell lung cancer[tiab]',
        '"PD-1"inhibitor[tiab] AND "non-small cell lung cancer"[tiab]',
    ),
    (
        '"messenger RNA[tiab] AND (vaccin*[tiab] OR "lipid nanoparticle"[tiab])',
        '"messenger RNA[tiab] AND (vaccin*"[tiab] OR "lipid nanoparticle"[tiab])',
    ),
    (
        '"Neoplasms[Mesh] NOT "case reports"[pt]',
        '"Neoplasms"[Mesh] NOT "case reports"[pt]',
    ),
    ('"Vaccines[Mesh]', '"Vaccines"[Mesh]'),
    ('"Vaccines[mh]"', "Vaccines[mh]"),
    ('"heart attack [tiab]', '"heart attack "[tiab]'),
    (
        '"heart attack [tiab] AND aspirin[tiab]',
        '"heart attack [tiab] AND aspirin"[tiab]',
    ),
    (
        '"mRNA vaccines[Mesh] OR "messenger RNA"[tiab]',
        '"mRNA vaccines"[Mesh] OR "messenger RNA"[tiab]',
    ),
    (
        '"T cells[Mesh] or "lymphocytes"[Mesh]',
        '"T cells"[Mesh] or "lymphocytes"[Mesh]',
    ),
    (
        '"PD-1"inhibitor[tiab] AND ("lung cancer"[tiab] OR NSCLC[tiab])',
        '"PD-1"inhibitor[tiab] AND ("lung cancer"[tiab] OR NSCLC[tiab])',
    ),
    (
        '"PD-1"inhibitors[tiab] AND ("melanoma"[Mesh])',
        '"PD-1"inhibitors[tiab] AND ("melanoma"[Mesh])',
    ),
    (
        '("PD-1"inhibitor[tiab] OR "anti-PD-1"[tiab]) AND melanoma[tiab]',
        '("PD-1"inhibitor[tiab] OR "anti-PD-1"[tiab]) AND melanoma[tiab]',
    ),
    (
        '("PD-1"inhibitor[tiab] OR pembrolizumab[tiab]) AND ("non-small cell lung cancer"[tiab])',
        '("PD-1"inhibitor[tiab] OR pembrolizumab[tiab]) AND ("non-small cell lung cancer"[tiab])',
    ),
    (
        '"COVID-19"vaccine[tiab] AND ("myocarditis"[tiab])',
        '"COVID-19"vaccine[tiab] AND ("myocarditis"[tiab])',
    ),
    ('"type 2"diabetes AND metformin', '"type 2"diabetes AND metformin'),
    (
        '"IL-6"signaling[tiab] AND "rheumatoid arthritis"[Mesh]',
        '"IL-6"signaling[tiab] AND "rheumatoid arthritis"[Mesh]',
    ),
    (
        '"IL-6"signaling[tiab] AND("rheumatoid arthritis"[Mesh])',
        '"IL-6"signaling[tiab] AND("rheumatoid arthritis"[Mesh])',
    ),
    (
        '"heart attack"[tiab] AND "aspirin"[tiab]',
        '"heart attack"[tiab] AND "aspirin"[tiab]',
    ),
    (
        "(“PD-1”inhibitor[tiab] OR “PD-L1”[tiab])",
        "(“PD-1”inhibitor[tiab] OR “PD-L1”[tiab])",
    ),
    (
        '"Alzheimer Disease[Mesh] AND (tau[tiab] OR "amyloid beta"[tiab])',
        '"Alzheimer Disease[Mesh] AND (tau"[tiab] OR "amyloid beta"[tiab])',
    ),
    (
        '"heart failure[tiab] AND ("SGLT2 inhibitors"[Mesh] OR empagliflozin[tiab])',
        '"heart failure"[tiab] AND ("SGLT2 inhibitors"[Mesh] OR empagliflozin[tiab])',
    ),
    (
        '("heart failure[tiab]) AND ("SGLT2 inhibitors"[Mesh])',
        '("heart failure"[tiab]) AND ("SGLT2 inhibitors"[Mesh])',
    ),
    (
        '"COVID-19[Mesh] AND ("mRNA vaccine"[tiab] OR "messenger RNA"[tiab])',
        '"COVID-19"[Mesh] AND ("mRNA vaccine"[tiab] OR "messenger RNA"[tiab])',
    ),
    (
        '"Alzheimer Disease"[Mesh] AND ("amyloid beta"[tiab] OR tau[tiab])',
        '"Alzheimer Disease"[Mesh] AND ("amyloid beta"[tiab] OR tau[tiab])',
    ),
    (
        '"breast cancer[tiab],"tamoxifen"[tiab]',
        '"breast cancer"[tiab],"tamoxifen"[tiab]',
    ),
    (
        "(influenza[Title/Abstract] OR flu[Title/Abstract]) AND treatment[Title/Abstract]",
        "(influenza[Title/Abstract] OR flu[Title/Abstract]) AND treatment[Title/Abstract]",
    ),
    (
        '"Breast Neoplasms"[Mesh] AND pregnancy[tiab]',
        '"Breast Neoplasms"[Mesh] AND pregnancy[tiab]',
    ),
    (
        '"Neoplasms/drug therapy"[Mesh] AND "immune checkpoint inhibitors"[tiab]',
        '"Neoplasms/drug therapy"[Mesh] AND "immune checkpoint inhibitors"[tiab]',
    ),
    (
        '"Smith J"[au] AND "deep learning"[tiab]',
        '"Smith J"[au] AND "deep learning"[tiab]',
    ),
    (
        '("heart attack"[tiab] OR "myocardial infarction"[Mesh]) NOT pediatric[tiab]',
        '("heart attack"[tiab] OR "myocardial infarction"[Mesh]) NOT pediatric[tiab]',
    ),
    (
        '(("type 2 diabetes"[tiab] OR T2DM[tiab]) AND (metformin[tiab] OR "SGLT2 inhibitors"[tiab])) AND 2020:2024[dp]',
        '(("type 2 diabetes"[tiab] OR T2DM[tiab]) AND (metformin[tiab] OR "SGLT2 inhibitors"[tiab])) AND 2020:2024[dp]',
    ),
    (
        '"COVID-19"[Mesh] AND "last 5 years"[dp]',
        '"COVID-19"[Mesh] AND "last 5 years"[dp]',
    ),
    (
        '"Alzheimer\'s disease"[tiab] AND tau[tiab]',
        '"Alzheimer\'s disease"[tiab] AND tau[tiab]',
    ),
    (
        '"Crohn’s disease"[tiab] AND infliximab[tiab]',
        '"Crohn’s disease"[tiab] AND infliximab[tiab]',
    ),
    (
        "Crohn’s disease[tiab] AND biologics[tiab]",
        "Crohn’s disease[tiab] AND biologics[tiab]",
    ),
    (
        '"CRISPR-Cas9"[tiab] AND "gene therapy"[tiab]',
        '"CRISPR-Cas9"[tiab] AND "gene therapy"[tiab]',
    ),
    ('"breast cancer and pregnancy"', "breast cancer and pregnancy"),
    ('"heart failure"', "heart failure"),
    ('statin* AND "muscle pain"', 'statin* AND "muscle pain"'),
    (
        "(“long COVID”[tiab] OR “post-COVID syndrome”[tiab]) AND fatigue[tiab]",
        "(“long COVID”[tiab] OR “post-COVID syndrome”[tiab]) AND fatigue[tiab]",
    ),
    (
        "«mRNA vaccine»[tiab] AND myocarditis[tiab]",
        "«mRNA vaccine»[tiab] AND myocarditis[tiab]",
    ),
    (
        "″heart attack″[tiab] AND aspirin[tiab]",
        "″heart attack″[tiab] AND aspirin[tiab]",
    ),
    (
        '12" catheter[tiab] AND complications[tiab]',
        '12" catheter[tiab] AND complications"[tiab]',
    ),
    (
        '"2[18F]FDG uptake"[Title/Abstract] AND lymphoma[tiab]',
        '"2"[18F]FDG uptake"[Title/Abstract] AND lymphoma"[tiab]',
    ),
    (
        '"Randomized Controlled Trial"[Publication Type] AND aspirin[tiab]',
        '"Randomized Controlled Trial"[Publication Type] AND aspirin[tiab]',
    ),
    (
        "(vitamin D[tiab] OR cholecalciferol[tiab]) AND depression[mesh]",
        "(vitamin D[tiab] OR cholecalciferol[tiab]) AND depression[Mesh]",
    ),
    (
        'aspirin[ti] AND "colorectal cancer"[ti] AND prevention',
        'aspirin[ti] AND "colorectal cancer"[ti] AND prevention',
    ),
    (
        '"carcinoma not otherwise specified"[tiab]',
        '"carcinoma not otherwise specified"[tiab]',
    ),
    (
        "obesity[MeSH Terms] AND exercise[MeSH Terms]",
        "obesity[MeSH Terms] AND exercise[MeSH Terms]",
    ),
    (
        '"sleep apnea"[tiab] AND (CPAP[tiab] OR "continuous positive airway pressure"[tiab])',
        '"sleep apnea"[tiab] AND (CPAP[tiab] OR "continuous positive airway pressure"[tiab])',
    ),
    (
        '"Hypertension"[MeSH] AND "Diet, Sodium-Restricted"[MeSH]',
        '"Hypertension"[Mesh] AND "Diet, Sodium-Restricted"[Mesh]',
    ),
    (
        "Based on randomized trials[tiab] AND aspirin[tiab]",
        "Based on randomized trials[tiab] AND aspirin[tiab]",
    ),
    (
        'based on "evidence-based medicine"[tiab]',
        'based on "evidence-based medicine"[tiab]',
    ),
    (
        "The following up[tiab] AND cohort[tiab]",
        "The following up[tiab] AND cohort[tiab]",
    ),
    (
        '"Here is the query: covid[tiab] AND vaccine[tiab]"',
        "covid[tiab] AND vaccine[tiab]",
    ),
    ('"Here is"[tiab] AND song', '"Here is"[tiab] AND song'),
    ('"heart attack" "aspirin"', 'heart attack" "aspirin'),
    ('"heart attack\'"', "heart attack'"),
    (
        'cancer[tiab] AND "quality of life:"[tiab]',
        'cancer[tiab] AND "quality of life:"[tiab]',
    ),
    ('"ratio 1:2"[tiab] AND dosage', '"ratio 1:2"[tiab] AND dosage'),
    (
        'Here is the query: "time-to-event: survival"[tiab] AND cancer',
        '"time-to-event: survival"[tiab] AND cancer',
    ),
    (
        "Here is the query: (a[tiab] OR b[tiab]) AND 2020/01/01:2024/12/31[dp]",
        "(a[tiab] OR b[tiab]) AND 2020/01/01:2024/12/31[dp]",
    ),
    (
        '"influenza vaccine"[tiab] OR "flu shot"[tiab] AND elderly[tiab]',
        '"influenza vaccine"[tiab] OR "flu shot"[tiab] AND elderly[tiab]',
    ),
    ('"breast cancer AND pregnancy"', "breast cancer AND pregnancy"),
    ('"breast cancer or pregnancy"', "breast cancer or pregnancy"),
    ('"breast cancer OR pregnancy"', "breast cancer OR pregnancy"),
    ('"Crohn"s disease" AND diet', '"Crohn"s disease" AND diet'),
    ("“heart attack”", "“heart attack”"),
    ('"heart attack', '"heart attack'),
    (
        '"vaccine efficacy[tiab] AND "elderly"[tiab]',
        '"vaccine efficacy"[tiab] AND "elderly"[tiab]',
    ),
    ('"" AND covid', '"" AND covid'),
    (
        '"COVID-19 vaccines"[Mesh] AND "adverse effects"[sh]',
        '"COVID-19 vaccines"[Mesh] AND "adverse effects"[sh]',
    ),
    (
        '"Neoplasms/drug therapy"[Mesh:NoExp]',
        '"Neoplasms/drug therapy"[Mesh:NoExp]',
    ),
    ("cancer[tiab]  AND   therapy[tiab]", "cancer[tiab]  AND   therapy[tiab]"),
    ('"cancer   therapy"[tiab]', '"cancer   therapy"[tiab]'),
    ('"T cells"[tiab] AND "CD8+"[tiab]', '"T cells"[tiab] AND "CD8+"[tiab]'),
    ('"5\' UTR"[tiab] AND translation', '"5\' UTR"[tiab] AND translation'),
    ('"3′ UTR"[tiab] AND microRNA', '"3′ UTR"[tiab] AND microRNA'),
    ('"3″ needle"[tiab]', '"3″ needle"[tiab]'),
    ("height 5'10\" AND obesity", "height 5'10\" AND obesity"),
    ("cleaned_lines[0]", "cleaned_lines[0]"),
    ("[ti]", "[ti]"),
    ('"a ', '"a'),
    ('AND"x"', 'AND"x"'),
    (
        "cleaned_lines[0].translate(_QUOTE_TRANSLATION)",
        "cleaned_lines[0].translate(_QUOTE_TRANSLATION)",
    ),
    ('order"x y"', 'order"x y"'),
    ('notch"x y"', 'notch"x y"'),
    ("“Crohn's disease”[tiab]", "“Crohn's disease”[tiab]"),
    ("“Crohn’s disease”[tiab]", "“Crohn’s disease”[tiab]"),
    ('"Crohn’s disease"[tiab]', '"Crohn’s disease"[tiab]'),
    ("Alzheimer's[tiab] AND 'x'", "Alzheimer's[tiab] AND 'x'"),
    ('"cancer OR tumour"', "cancer OR tumour"),
    ('"x"', "x"),
    ('"[18F]FDG up"', "[18F]FDG up"),
    ('"a [b] c"', "a [b] c"),
    ('"2020/01/01"', "2020/01/01"),
    ('"hip  pain"', "hip  pain"),
    ('"a(b"', "a(b"),
    ("(?<![A-Za-z0-9])(AND|OR|NOT)$", "(?<![A-Za-z0-9])(AND|OR|NOT)$"),
    ("(AND|OR|NOT)(?![A-Za-z0-9])", "(AND|OR|NOT)(?![A-Za-z0-9])"),
    ('NOT"x y"', 'NOT"x y"'),
    ('-"x y"', '-"x y"'),
    ('cancer[tiab] NOT"x y"[tiab]', 'cancer[tiab] NOT"x y"[tiab]'),
    ('"cancer[mj] AND x"', "cancer[mj] AND x"),
    ("cancer[mj] AND x", "cancer[mj] AND x"),
    ('"nature[so]"', "nature[so]"),
    ("nature[so]", "nature[so]"),
    ('"0028-0836[is]"', "0028-0836[is]"),
    ("0028-0836[is]", "0028-0836[is]"),
    ("mRNA[Title/Abstract]", "mRNA[Title/Abstract]"),
    (
        '"heart attack"AND x[Mesh] AND"a [Mesh] b"[Mesh]',
        '"heart attack"AND x[Mesh] AND"a "[Mesh] b"[Mesh]',
    ),
    (' " ', ""),
    ('5"', '5"'),
    ('"foo "[bar]"[Title/Abstract]', '"foo "[bar]"[Title/Abstract]'),
    (
        '"2"[18F]FDG uptake"[Title/Abstract]',
        '"2"[18F]FDG uptake"[Title/Abstract]',
    ),
    (
        '"a"[b" AND vaccin*"[Title/Abstract]',
        '"a"[b" AND vaccin*"[Title/Abstract]',
    ),
    (
        '"leaky OR "good phrase" AND vaccin*"[Title/Abstract]',
        '"leaky OR "good phrase" AND vaccin*"[Title/Abstract]',
    ),
    ('"one"[T] AND "two"[T', '"one"[T] AND "two"[T'),
    ('"foo[bar]"[Title/Abstract]', '"foo"[bar]"[Title/Abstract]'),
    ('"a[b AND c"[Title/Abstract]', '"a"[b AND c"[Title/Abstract]'),
    (
        '"aspirin[tiab] AND ("heart attack"[tiab] OR MI[tiab])"',
        'aspirin[tiab] AND ("heart attack"[tiab] OR MI[tiab])',
    ),
]


def _optimize(response: str) -> str:
    llm = Mock()
    llm.invoke.return_value = Mock(content=response)
    engine = PubMedSearchEngine(llm=llm, optimize_queries=True)
    return engine._optimize_query_for_pubmed("research question")


@pytest.mark.parametrize(
    ("response", "expected"),
    [
        # Issue #7278: both quotes pair into one literal phrase spanning the
        # OR group, so PubMed returns no results.
        (
            '(vaccine"[Title/Abstract] OR immunization"[Title/Abstract]) '
            "AND influenza[Title/Abstract]",
            "(vaccine[Title/Abstract] OR immunization[Title/Abstract]) "
            "AND influenza[Title/Abstract]",
        ),
        (
            'vaccine[Title/Abstract] AND influenza"[Title/Abstract]',
            "vaccine[Title/Abstract] AND influenza[Title/Abstract]",
        ),
        ('cancer"[tiab]', "cancer[tiab]"),
        ('vaccin*"[tiab] OR (flu)"[tiab]', "vaccin*[tiab] OR (flu)[tiab]"),
        # Stray closers left behind by the wrapper strip and the lead-in cut.
        ('"heart attack"[tiab]"', "heart attack[tiab]"),
        ('here is "time:course"[tiab]', "course[tiab]"),
        # Must run before the unclosed-quote repair, which would pair the
        # stray closer with the later spaced field tag.
        ('vaccine"[tiab] AND flu [tiab]', "vaccine[tiab] AND flu [tiab]"),
    ],
)
def test_drops_stray_closing_quotes(response, expected):
    assert _optimize(response) == expected


@pytest.mark.parametrize(
    ("response", "expected"),
    [
        # A real phrase alongside a stray closer: the stray is kept.
        (
            'vaccine"[Title/Abstract] OR "good phrase"[Mesh]',
            'vaccine"[Title/Abstract] OR "good phrase"[Mesh]',
        ),
        # Quotes that are not glued to a term, or not followed by a field tag,
        # are left to the existing unclosed-quote repair.
        ('(vaccine "[tiab] OR flu[tiab])', '(vaccine "[tiab] OR flu"[tiab])'),
        ('("[tiab] OR flu[tiab])', '("[tiab] OR flu"[tiab])'),
        ('PD-1" inhibitor[tiab]', 'PD-1" inhibitor"[tiab]'),
        # Real phrases starting with "[" and a digit, opened right after
        # text, or after an invisible character that is not \s.
        ('cancer AND"[18F]FDG PET"[tiab]', 'cancer AND"[18F]FDG PET"[tiab]'),
        (
            '(PET[tiab] OR"[18F]FDG"[tiab]) AND lymphoma[tiab]',
            '(PET[tiab] OR"[18F]FDG"[tiab]) AND lymphoma[tiab]',
        ),
        ('x[ti]"[18F]FDG"[ti]', 'x[ti]"[18F]FDG"[ti]'),
        (
            'cancer AND \u200b"[beta]amyloid"[tiab]',
            'cancer AND \u200b"[beta]amyloid"[tiab]',
        ),
        (
            '\ufeff"[beta]amyloid"[tiab] AND x[tiab]',
            '\ufeff"[beta]amyloid"[tiab] AND x[tiab]',
        ),
        (
            'cancer AND \u2060"[beta]amyloid"[tiab]',
            'cancer AND \u2060"[beta]amyloid"[tiab]',
        ),
        (
            'cancer AND \u180e"[beta]amyloid"[tiab]',
            'cancer AND \u180e"[beta]amyloid"[tiab]',
        ),
    ],
)
def test_other_quotes_are_not_treated_as_stray(response, expected):
    assert _optimize(response) == expected


@pytest.mark.parametrize(
    ("response", "expected"),
    CORPUS,
)
def test_regression_corpus_matches_previous_behavior(response, expected):
    assert _optimize(response) == expected