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>>=3B Date: Thu=2C 11 Nov 201=
> 0 12:25:15 -0500<br>>=3B From: [email protected]<br>>=3B To: g...@res=
> earch.att.com=3B [email protected]<br>>=3B Subject: Re: [ast-us=
> ers] Matching a new line in a ~(E)=2C ~(P) regex?<br>>=3B CC: ast-us...@r=
> esearch.att.com<br>>=3B <br>>=3B <br>>=3B On Thu=2C 11 Nov 2010 18:16=
> :27 +0100 =3D?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?=3D wrote:<br>>=3B >=3B=
> What is the m in ~(Em)?<br>>=3B <br>>=3B right=2C this needs to be doc=
> umented<br>>=3B its on the todo list<br>>=3B <br>>=3B 'm' turns on th=
> e standard regex REG_NEWLINE flag<br>>=3B you can see all the '<=3Bchar=
> >=3B' <=3B=3D>=3B REG_* flag mappings in<br>>=3B
> src/lib/libast/re=
> gex/regcomp.c<br>>=3B <br>>=3B >=3B Olga<br>>=3B <br>>=3B _______=
> ________________________________________<br>>=3B ast-users mailing list<b=
> r>>=3B [email protected]<br>>=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