[Python] Ricerca e sostituzione con regex

Marco Beri marcoberi a gmail.com
Lun 17 Giu 2019 23:16:25 CEST


On Mon, 17 Jun 2019, 22:57 Daniele Zambelli, <daniele.zambelli a gmail.com>
wrote:

Mi resta ancora un problema:
>
> Nella situazione (poco probabile) che nel sorgente LaTeX ci sia la
> sequenza "\$" in questo caso il dollaro non va considerato come un
> delimitatore di formule. Come posso fare a convincere re a saltare i
> dollari preceduti da "\"?
>
> È possibile?
>

Positive and Negative Lookbehind

Lookbehind has the same effect, but works backwards. It tells the regex
engine to temporarily step backwards in the string, to check if the text
inside the lookbehind can be matched there. (?<!a)b matches a "b" that is
not preceded by an "a", using negative lookbehind. It doesn't match cab,
but matches the b (and only the b) in bed or debt. (?<=a)b(positive
lookbehind) matches the b (and only the b) in cab, but does not match bed
 or debt.



Ciao.

Marco.
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20190617/580486d0/attachment.html>


Maggiori informazioni sulla lista Python