.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [ESPRESSIONI REGOLARI] Perchè si pianta?!?!? (http://www.dsy.it/forum/showthread.php?threadid=18933)


Posted by ripe on 16-04-2005 18:58:

[ESPRESSIONI REGOLARI] Perchè si pianta?!?!?

Ho scritto questa regex per cercare tutti i percorsi di oggetti inseriti all'interno degli attributi dei tag Html:

code:
<(\w*)\s+(\w*)\s*=\s*(""|')\s*(([.\\\/]*(\w+))+.(\w+))\s*(""|')\s+/?>


Quando la eseguo mi entra in un ciclo infinito e non riesce a portare a termine il compito.

Se invece la modifico per cercare solo oggetti con percorso semplice funziona:

code:
<(\w*)\s+(\w*)\s*=\s*(""|')\s*([.\\\/]*(\w+).(\w+))\s*(""|')\s+/?>


Chi mi sa spiegare il perchè?!

Ah, il motore delle Regex è quello di Asp.Net!

Grazieeeeee

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by ripe on 16-04-2005 19:08:

Aggiungo che se eseguo la prima espressione su un tag singolo del tipo <img src="../Public/Images/Prova.gif" /> funziona correttamente estraendo "../Public/Images/Prova.gif", mentre se la eseguo su un file Html completo si pianta... :?

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by ripe on 17-04-2005 09:46:

Nessuno ha una minima idea, un suggerimento......?! :(

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


Posted by Gusher on 17-04-2005 11:14:

Premesso che non conosco ASP.net, ma ad occhio sembrerebbe un problema di modificatore mancante.
Facendo riferimento a PHP ed alle espressioni regolari PERL compatibili, ti serve specificare l'equivalente di PCRE_DOTALL

<http://it2.php.net/manual/it/refere...n.modifiers.php>


HTH


Posted by ripe on 17-04-2005 12:08:

Ti ringrazio per il consiglio, ma avevo già completamente cambiato espressione!

code:
<[^>]*\n?.*=[""']?(.*\.(jpg|jpeg|gif|png))[""']?.*\n?[^<]*>


In questo modo isolo solo le immagini! ;)

Ciaoooooo

Ale

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»


All times are GMT. The time now is 00:07.
Show all 5 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.