[net.bugs.v7] awk vs. regular expressions starting with equal sign

henry@utzoo.UUCP (Henry Spencer) (12/12/84)

There is a fundamental lexical ambiguity in awk:  when you see "/=",
is this the divide-by-and-assign operator, or the start of a regular
expression which happens to begin with an equal sign?  Awk thinks it
is the operator, which means you can't start a regular expression with
an equal sign, ever.  To really write such a pattern, you have to resort
to schemes like "/.=/" or "/.*=/".  How annoying.  I can see no real fix.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

crl@pur-phy.UUCP (Charles LaBrec) (12/13/84)

Try /\=/.  It worked for me.

Charles LaBrec
UUCP:		pur-ee!Physics:crl, purdue!Physics:crl
INTERNET:	crl @ pur-phy.UUCP

jonab@sdcrdcf.UUCP (Jonathan Biggar) (12/13/84)

In article <4770@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes:
>There is a fundamental lexical ambiguity in awk:  when you see "/=",
>is this the divide-by-and-assign operator, or the start of a regular
>expression which happens to begin with an equal sign?  Awk thinks it
>is the operator, which means you can't start a regular expression with
>an equal sign, ever.  To really write such a pattern, you have to resort
>to schemes like "/.=/" or "/.*=/".  How annoying.  I can see no real fix.

You should use "/[=]/", it is better.

Jon Biggar
{allegra,burdvax,cbosgd,hplabs,ihnp4,sdccsu3}!sdcrdcf!jonab

bobr@zeus.UUCP (Robert Reed) (12/15/84)

> There is a fundamental lexical ambiguity in awk:  when you see "/=",
> is this the divide-by-and-assign operator, or the start of a regular
> expression which happens to begin with an equal sign? 
>
> 				Henry Spencer @ U of Toronto Zoology
> 				{allegra,ihnp4,linus,decvax}!utzoo!henry

You can easily get around it by escaping it, such as

	awk '/\= / {...}' ...

I tried this on our 4.2BSD system and it seems to work just fine.

-- 
Robert Reed, Logic Design Systems Division, tektronix!teklds!bobr

henry@utzoo.UUCP (Henry Spencer) (12/16/84)

> Try /\=/.  It worked for me.

About six people have told me this, or variants of this.  I *thought*
it was clear from my original posting that I *know* how to work around
the problem.  My point was the absence of a *fix*, not the absence of a
workaround kludge.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry