| |||||||||||
| |||||||||||
Replacing parts of lines Posted by TedH (TedH), 2 February 2008 Hi Graham, how's everything there?I have a file with hundreds of lines and double that in "parenthesis content" Each line = somekindoftext (aaa) (bb) Each one is different. I'm trying to get rid of all the parenthesis and everything in them. I've tried this to no avail, so must be missing somethng. Code:
Hope you can help, Cheers - Ted Posted by KevinAD (KevinAD), 2 February 2008 If I may provide assistance:## Replace all parenthesis and everything in them $file="loc.txt"; $first=" ("; $last=")"; $blank=""; open( CURRENTFILE, "$file"); while ( <CURRENTFILE> ) { s/ \Q$first\E (.*?) \Q$last\E /$blank/gx; print; } close(CURRENTFILE); Ask questions if needed. Posted by TedH (TedH), 2 February 2008 Thanks Kevin - TedThis page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |