Re: psql/pg_dump vs. dollar signs in identifiers - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: psql/pg_dump vs. dollar signs in identifiers
Date
Msg-id 871wfh9vvc.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: psql/pg_dump vs. dollar signs in identifiers  ("Jim C. Nasby" <decibel@decibel.org>)
List pgsql-hackers
"Jim C. Nasby" <decibel@decibel.org> writes:

> Unless you're doing muti-line regex, what's the point of a $ anywhere
> but the end of the expression? Am I missing something? Likewise with ^.

Leaving out the backslashes, you can do things like (foo$|baz|qux)(baz|qux|)
to say that all 9 combinations of those two tokens are valid except that foo
must be followed by the empty second half.

But it can always be refactored into something more normal like
(foo|((baz|qux)(baz|qux)?))

> I'm inclined to escape $ as Tom suggested.

Yeah, I have a tendency to look for the most obscure counter-example if only
to be sure I really understand precisely how obscure it is. I do agree that
it's not a realistic concern. Especially since I never even realized we
handled regexps here at all :)

IIRC some regexp engines don't actually treat $ specially except at the end of
the regexp at all. Tom's just suggesting doing the same thing here where
complicated regexps are even *less* likely and dollars as literals more.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: psql/pg_dump vs. dollar signs in identifiers
Next
From: Gregory Stark
Date:
Subject: Re: PQescapeBytea* version for parameters