On 20 June 2012 06:43, ольга крыжановская <[email protected]> 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 ----

<RANT>
I'm likely going to be sorry for this email, but:

For crying out loud.
For gods sake.
What is this?

1. What you do with these regex is useful. Very very useful.
2. What you archive is magic for those not being initiated in the
rituals of regex
3. ksh93 and libast seem to have a very, very powerful regex engine

But:

Where... is... this... documented?

For a *long* time I would really appreciate that the --man pages for
grep, sed and ksh include a complete list of regex commands, including
examples. Also example code would be very, very nice. Neither ast-open
nor ast-ksh has *any* godforsaken example code. It does *not* help if
you have one of the best regex engines in this world when only those
initiated in the ways of ast regex can use it.
</RANT>

Sorry, bad day today. Started bad, will end in disaster.

Lionel

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

Reply via email to