View previous topic :: View next topic |
Author |
Message |
MeMyselfAndI l33t
Joined: 15 Nov 2005 Posts: 784 Location: Between the monitor and the chair
|
Posted: Wed May 10, 2006 4:58 pm Post subject: [OT]espressioni regolari |
|
|
Dal basso della mia ignoranza chiedo a aiuto a qualcuno che ne sa sicuramente piu' di me:
Da questo
Code: | <title><![CDATA[testo a caso]]></title> |
vorrei ottenere questo
con qualcosa di meglio di questa espressione regolare
Code: | sed -e 's/<title><\!\[CDATA\[//'| sed -e 's/]]><\/title>//' |
Avete suggerimenti?Magari un'espressione un po piu' generica
grazie! |
|
Back to top |
|
|
Luca89 Advocate
Joined: 27 Apr 2005 Posts: 2107 Location: Agrigento (Italy)
|
Posted: Wed May 10, 2006 5:17 pm Post subject: |
|
|
forse si potrebbe usare:
Code: | sed -e 's/<title><\!\[CDATA\[\(.*\)]]><\/title>/\1/' |
_________________ Running Fast! |
|
Back to top |
|
|
MeMyselfAndI l33t
Joined: 15 Nov 2005 Posts: 784 Location: Between the monitor and the chair
|
Posted: Wed May 10, 2006 5:25 pm Post subject: |
|
|
Mi sa che mi sono spiegato male,, grazie cmq per la risposta, perfettamente funzonante, ma mi serviva qualcosa per togliere quel testo senza specificarlo espressamente... non so se e' chiaro, ma volevo togliere ad esempio CDATA senza scrivere un'espressione regolare apposta pe rquella stringa... ma sinceramente guardando un paio di guide su internet non ho ben capito come matchare un caso piu' generico della stringa stessa senza andare a cancellare tutto il testo. |
|
Back to top |
|
|
Luca89 Advocate
Joined: 27 Apr 2005 Posts: 2107 Location: Agrigento (Italy)
|
Posted: Wed May 10, 2006 5:32 pm Post subject: |
|
|
se devi eliminare solo CDATA basta fare:
Code: | sed -e 's/\[CDATA\[\(.*\)\]\]/\1/' |
_________________ Running Fast! |
|
Back to top |
|
|
makoomba Bodhisattva
Joined: 03 Jun 2004 Posts: 1856
|
Posted: Wed May 10, 2006 5:41 pm Post subject: |
|
|
Code: | echo '<title><![CDATA[testo a caso]]></title>' | perl -pe 's/.*\[([^\]|^\[]+)\].*/$1/'
testo a caso
|
_________________ When all else fails, read the instructions. |
|
Back to top |
|
|
MeMyselfAndI l33t
Joined: 15 Nov 2005 Posts: 784 Location: Between the monitor and the chair
|
Posted: Thu May 11, 2006 11:07 am Post subject: |
|
|
Grazie mille! davvero gentilissimi |
|
Back to top |
|
|
|