[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: script per analisi di log



On Fri, 19 Oct 2012 19:15:39 +0200
Davide Prina <davide.prina@gmail.com> wrote:
> 
> ---8<------8<------8<---start script---8<------8<------8<---
> #!/bin/bash
> 
> if [[ "$1" == "" ]] || [[ ! -f "$1" ]]; then
>   echo $0 nomefile.est
>   exit
> fi
> 
> StartTag="<SOAP-ENV:Envelope"
> EndTag="<\/SOAP-ENV:Envelope>"
> 
> StartChar="¹"
> EndChar="²"
> 
> echo "$(cat "$1")" | tr "\n" " " | sed 
> "s/$StartTag/$StartChar/g;s/$EndTag/$EndChar/g;s/^[^$StartChar]*//;s/$EndChar[^$StartChar]*/$EndChar/g;s/$StartChar\([^$EndChar]*\)$EndChar/\1\n/g"
> ---8<------8<------8<---end script---8<------8<------8<---
perche' certe cose e' meglio non dimenticarle, perche' non si dovrebbe
parsare html(o xml) con delle espressioni regolari

post originale:
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
articolo a riguardo:
http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html
 

-- 
Francesco Berni  -  kurojishi
Registered Linux User #512920
GPG: A1FB5252

Attachment: signature.asc
Description: PGP signature


Reply to: