I need to return only non-repeating elements from a string.
This is my current regex:
/{{([1-9]|[1-9][0-9])}}/gm
Here are some samples of what I need:
{{1}}{{2}}{{3}}{{4}}{{5}}{{1}} => {{1}}{{2}}{{3}}{{4}}{{5}}
{{1}}{{2}}{{3}}{{4}}{{2}}{{1}} => {{1}}{{2}}{{3}}{{4}}
{{1}}{{2}}{{2}}{{4}}{{1}}{{1}} => {{1}}{{2}}{{4}}
I have tried the following lookaround:
/{{([1-9]|[1-9][0-9])}}(?!.*\1)/gm
Kind of works for this example, but it get the last element instead of the first:
{{1}}{{2}}{{3}}{{4}}{{5}}{{1}} => {{2}}{{3}}{{4}}{{5}}{{1}}
With this example it don't work:
Olá, {{1}}
Só pra lembrar, sua consulta foi agendada para o dia {{2}} às {{3}}h.
Por favor, não se atrase
Se por acaso tiver algum imprevisto e não puder comparecer, nos avisem com {{4}}h de antecedência.
{{1}}, te esperamos aqui!
The string above returns all elements:
{{1}}{{2}}{{3}}{{4}}{{1}}