Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[OT]espressioni regolari
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
MeMyselfAndI
l33t
l33t


Joined: 15 Nov 2005
Posts: 784
Location: Between the monitor and the chair

PostPosted: Wed May 10, 2006 4:58 pm    Post subject: [OT]espressioni regolari Reply with quote

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
Code:
testo a caso


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
View user's profile Send private message
Luca89
Advocate
Advocate


Joined: 27 Apr 2005
Posts: 2107
Location: Agrigento (Italy)

PostPosted: Wed May 10, 2006 5:17 pm    Post subject: Reply with quote

forse si potrebbe usare:

Code:
sed -e 's/<title><\!\[CDATA\[\(.*\)]]><\/title>/\1/'

_________________
Running Fast!
Back to top
View user's profile Send private message
MeMyselfAndI
l33t
l33t


Joined: 15 Nov 2005
Posts: 784
Location: Between the monitor and the chair

PostPosted: Wed May 10, 2006 5:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
Luca89
Advocate
Advocate


Joined: 27 Apr 2005
Posts: 2107
Location: Agrigento (Italy)

PostPosted: Wed May 10, 2006 5:32 pm    Post subject: Reply with quote

se devi eliminare solo CDATA basta fare:

Code:
sed -e 's/\[CDATA\[\(.*\)\]\]/\1/'

_________________
Running Fast!
Back to top
View user's profile Send private message
makoomba
Bodhisattva
Bodhisattva


Joined: 03 Jun 2004
Posts: 1856

PostPosted: Wed May 10, 2006 5:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
MeMyselfAndI
l33t
l33t


Joined: 15 Nov 2005
Posts: 784
Location: Between the monitor and the chair

PostPosted: Thu May 11, 2006 11:07 am    Post subject: Reply with quote

Grazie mille! davvero gentilissimi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum