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