nice
non-greedy matching, along with negation, are the hardest for me to 
conceptualize

On Wed, 20 Jun 2012 06:43:14 +0200 =?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?= wrote:
> Glenn, this looks right:
> xmltext='<h1><div> a text </div><!-- a comment (<disabled>) --></h1>'

> dummy="${xmltext//~(Ex)(?:
>        (<!--.+-->)+?|   # xml comments
>        (<.+>)+?|  # xml tags
>        ([^[><]]+)+?     # xml text
>        )/dummy}"
> print -v .sh.match

> (
>         (
>                 [0]='<h1>'
>                 [1]='<div>'
>                 [2]=' '
>                 [3]=a
>                 [4]=' '
>                 [5]=t
>                 [6]=e
>                 [7]=x
>                 [8]=t
>                 [9]=' '
>                 [10]='</div>'
>                 [11]='<!-- a comment (<disabled>) -->'
>                 [12]='</h1>'
>         )
>         (
>                 [11]='<!-- a comment (<disabled>) -->'
>         )
>         (
>                 [0]='<h1>'
>                 [1]='<div>'
>                 [10]='</div>'
>                 [12]='</h1>'
>         )
>         (
>                 [2]=' '
>                 [3]=a
>                 [4]=' '
>                 [5]=t
>                 [6]=e
>                 [7]=x
>                 [8]=t
>                 [9]=' '
>         )
> )

> Trick is: Remove global 'not greedy' -g from ~(Ex) and add it to each
> pattern, i.e. +?

> Olga

> On Mon, Jun 18, 2012 at 5:12 PM, ÏÌØÇÁ ËÒÙÖÁÎÏ×ÓËÁÑ
> <[email protected]> wrote:
> > Glenn, how does the egrep pattern below look like if I want a xgrep
> > pattern instead?
> > ----- cutme ----
> > xmltext='<h1><div> a text </div><!-- a comment (<disabled>) --></h1>'
> >
> > dummy="${xmltext//~(Ex-g)(?:
> > # š š š (<!--.+-->)| š # xml comments
> > š š š š(<.+>)| š# xml tags
> > š š š š([^[><]]+) š š # xml text
> > š š š š)/dummy}"
> > print -v .sh.match
> > ----- cutme ----
> >
> > Olga
> > --
> > š š š ,šš _š š š š š š š š š š š š š š š š š š _šš ,
> > š šš { \/`o;====-š š Olga Kryzhanovskašš -====;o`\/ }
> > .----'-/`-/š šš [email protected]šš \-`\-'----.
> > š`'-..-| /š š šš http://twitter.com/fleytaš šš \ |-..-'`
> > š š š /\/\š šš Solaris/BSD//C/C++ programmeršš /\/\
> > š š š `--`š š š š š š š š š š š š š š š š š š š `--`

> -- 
> š š š ,šš _š š š š š š š š š š š š š š š š š š _šš ,
> š šš { \/`o;====-š š Olga Kryzhanovskašš -====;o`\/ }
> .----'-/`-/š šš [email protected]šš \-`\-'----.
> š`'-..-| /š š šš http://twitter.com/fleytaš šš \ |-..-'`
> š š š /\/\š šš Solaris/BSD//C/C++ programmeršš /\/\
> š š š `--`š š š š š š š š š š š š š š š š š š š `--`

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to