[Cialug] Text file munging

Matthew Nuzum newz at bearfruit.org
Thu Jun 18 14:19:33 CDT 2009


On Thu, Jun 18, 2009 at 1:46 PM, chris <chris at ia.gov> wrote:

> > end. I need to remove
> >          <key>remote-id</key>
> >          <string>4294</string>
>
> If I understand what you need this may work, if not tell me w where I went
> wrong and I'll fix it.
>
> perl -p -i -e 's/<(key|string)>.+<\/(key|string)>//' *
>
>
> That'll *modify the original file* in place and leave a blank line where
> any
>
> <key>.+</key>
> <string>.+</string>
>
>
Well, that could cause problems if there are other tags between the end of
</key> and beginning of </string> since the regex will be greedy. It will
actually match <key>.+</strong>
So <(key|string)>[^<]+</(key|string)> would work better, right?

-- 
Matthew Nuzum
newz2000 on freenode, skype, linkedin, identi.ca and twitter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20090618/df12265c/attachment-0001.htm 


More information about the Cialug mailing list