I had to look at this for a bit
REG_SPAN allows <newline> to be matched when REG_NEWLINE is set

this script illustrates
---
# ~(E)    REG_NEWLINE=0 REG_SPAN=0
# ~(Es)   REG_NEWLINE=0 REG_SPAN=1
# ~(Em)   REG_NEWLINE=1 REG_SPAN=0
# ~(Ems)  REG_NEWLINE=1 REG_SPAN=1
string=$'one\ntwo'
for expr in '.two/AHA' '^two/AHA'
do      for mode in E Es Em Ems
        do      eval 'result=${string/~('$mode')'$expr'}'
                printf $'%-3s %-12s %q\n' "$mode" "$expr" "$result"
        done
done
---
the output is
---
E   .two/AHA     oneAHA
Es  .two/AHA     oneAHA
Em  .two/AHA     $'one\ntwo'
Ems .two/AHA     oneAHA
E   ^two/AHA     $'one\ntwo'
Es  ^two/AHA     $'one\ntwo'
Em  ^two/AHA     $'one\nAHA'
Ems ^two/AHA     $'one\nAHA'
---

a difference between the two expressions is . consumes
a string character when it matches and ^ does not

On Thu, 11 Nov 2010 13:51:44 -0500 Finnbarr Murphy wrote:
> What is the difference between REG_NEWLINE and REG_SPAN?
> They seem to be intertwined in some fashion.

> > Date: Thu=2C 11 Nov 2010 12:25:15 -0500
> > From: [email protected]
> > To: [email protected]=3b [email protected]
> > Subject: Re: [ast-users] Matching a new line in a ~(E)=2C ~(P) regex?
> > CC: [email protected]
> >=20
> >=20
> > On Thu=2C 11 Nov 2010 18:16:27 +0100 =3D?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8H=
> R?=3D wrote:
> > > What is the m in ~(Em)?
> >=20
> > right=2C this needs to be documented
> > its on the todo list
> >=20
> > 'm' turns on the standard regex REG_NEWLINE flag
> > you can see all the '<char>' <=3D> REG_* flag mappings in
> >     src/lib/libast/regex/regcomp.c
> >=20
> > > Olga
> >=20
> > _______________________________________________
> > ast-users mailing list
> > [email protected]
> > https://mailman.research.att.com/mailman/listinfo/ast-users
>                                         =

> --_31a7c15e-6887-49b8-8bc8-fa5698e53aa3_
> Content-Type: text/html; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable

> <html>
> <head>
> <style><!--
> .hmmessage P
> {
> margin:0px=3B
> padding:0px
> }
> body.hmmessage
> {
> font-size: 10pt=3B
> font-family:Tahoma
> }
> --></style>
> </head>
> <body class=3D'hmmessage'>
> <br>What is the difference between REG_NEWLINE and REG_SPAN?<br>They seem t=
> o be intertwined in some fashion.<br><br><br>&gt=3B Date: Thu=2C 11 Nov 201=
> 0 12:25:15 -0500<br>&gt=3B From: [email protected]<br>&gt=3B To: g...@res=
> earch.att.com=3B [email protected]<br>&gt=3B Subject: Re: [ast-us=
> ers] Matching a new line in a ~(E)=2C ~(P) regex?<br>&gt=3B CC: ast-us...@r=
> esearch.att.com<br>&gt=3B <br>&gt=3B <br>&gt=3B On Thu=2C 11 Nov 2010 18:16=
> :27 +0100 =3D?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?=3D wrote:<br>&gt=3B &gt=3B=
>  What is the m in ~(Em)?<br>&gt=3B <br>&gt=3B right=2C this needs to be doc=
> umented<br>&gt=3B its on the todo list<br>&gt=3B <br>&gt=3B 'm' turns on th=
> e standard regex REG_NEWLINE flag<br>&gt=3B you can see all the '&lt=3Bchar=
> &gt=3B' &lt=3B=3D&gt=3B REG_* flag mappings in<br>&gt=3B      
> src/lib/libast/re=
> gex/regcomp.c<br>&gt=3B <br>&gt=3B &gt=3B Olga<br>&gt=3B <br>&gt=3B _______=
> ________________________________________<br>&gt=3B ast-users mailing list<b=
> r>&gt=3B [email protected]<br>&gt=3B https://mailman.research.att.=
> com/mailman/listinfo/ast-users<br>                                      
> </body>
> </html>=

> --_31a7c15e-6887-49b8-8bc8-fa5698e53aa3_--

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

Reply via email to