[Python] Regex logic in numpy/torch

Discussão em 'Python' iniciado por Stack, Abril 30, 2025.

  1. Stack

    Stack Membro Participativo

    Morning,

    This is a kinda 'open question'.

    Is there a way to find number sequences, following certain pattern, in a numpy/torch array in a similar way as a regex works?

    Let's say i wanna find all occurences of a negative number, followed by a variable number of positive numbers and then another negative number in an array, is there a "direct way" to achieve that?

    I know there are a lot of approaches i can do to achieve this, not to even mention that i could just upfront stringify the array and use a literal regex, but is there a "native equivalent" to a regex but for numbers in numpy/torch?

    Thanks in advance!

    Continue reading...

Compartilhe esta Página