79826691

Date: 2025-11-21 15:36:21
Score: 0.5
Natty:
Report link

What I understood from your question is that you want 'n' to match with both 'n' and 'ñ' when doing a word search. If that is the case, you can simply define an equivalence table and construct a pattern from it:

import re

multi_match = {
    'n': r'[nñ]',
    'e': r'[eé]',
    # and more
}

def word_search(text:str, word: str):
    pattern = ''
    for c in word:
        pattern += multi_match[c] if c in multi_match else c

    return re.findall(pattern, text)

text = 'épée epee piñata pinata'

print(word_search(text, 'epee'))
print(word_search(text, 'épée'))
print(word_search(text, 'pinata'))
print(word_search(text, 'piñata'))

Output:

['épée', 'epee']
['épée']
['piñata', 'pinata']
['piñata']

Of course you could also define equivalences so that 'ñ' matches with both 'n' and 'ñ', if that is something that you want.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What I
  • Low reputation (1):
Posted by: MrXerios