1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python multiple repeat Error

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to determine whether a term appears in a string.
    Before and after the term must appear a space, and a standard suffix is also allowed.
    Example:

    term: google
    string: "I love google!!! "
    result: found

    term: dog
    string: "I love dogs "
    result: found


    I'm trying the following code:

    regexPart1 = "\s"
    regexPart2 = "(?:s|'s|!+|,|.|;|:|\(|\)|\"|\?+)?\s"
    p = re.compile(regexPart1 + term + regexPart2 , re.IGNORECASE)


    and get the error:

    raise error("multiple repeat")
    sre_constants.error: multiple repeat


    Update
    Real code that fails:

    term = 'lg incite" OR author:"http++www.dealitem.com" OR "for sale'
    regexPart1 = r"\s"
    regexPart2 = r"(?:s|'s|!+|,|.|;|:|\(|\)|\"|\?+)?\s"
    p = re.compile(regexPart1 + term + regexPart2 , re.IGNORECASE)


    On the other hand, the following term passes smoothly (+ instead of ++)

    term = 'lg incite" OR author:"http+www.dealitem.com" OR "for sale'

    Continue reading...

Compartilhe esta Página