How to find elements whose id has prefix “Translations_”?

I have a html

<details data-level="2" open="">
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_2">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_6">Translations</h5>
        </summary>
    </details>
</details>

I would like to extract such elements which are signified by Translation

<h5 id="Translations">Translations</h5>
<h5 id="Translations_2">Translations</h5>
<h5 id="Translations_6">Translations</h5>

With soup.select('details[data-level] > summary[class] > h5[id="Translations"]'), I’m able to extract only the first element. Could you please explain how to modify my code to do so?

from bs4 import BeautifulSoup

texte = """
<details data-level="2" open="">
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_2">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_6">Translations</h5>
        </summary>
    </details>
</details>
"""

soup = BeautifulSoup(texte, 'html.parser')
soup.select('details[data-level] > summary[class] > h5[id="Translations"]')

Answer

You can use a attr^=value CSS selector.

Represents elements with an attribute name of attr whose value is prefixed (preceded) by value.

from bs4 import BeautifulSoup

data = '''
<details data-level="2" open="">
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_2">Translations</h5>
        </summary>
    </details>
    <details data-level="5" open="">
        <summary class="section-heading">
            <h5 id="Translations_6">Translations</h5>
        </summary>
    </details>
</details>
'''

soup = BeautifulSoup(data, 'html.parser')

for e in soup.select('h5[id^=Translations]'):
    print(e)