Re: repeated characters in SQL

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: rashapoo(at)gmail(dot)com
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: repeated characters in SQL
Date: 2016-01-24 18:31:12
Message-ID: CA+bJJbxKid0PMd7c=40DQ8rofW-rR52HeU0MUtD13Z8whkQ7=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jan 24, 2016 at 7:05 PM, <rashapoo(at)gmail(dot)com> wrote:
> I guess the escape character (which is not needed in, say, Notepad++) threw
> me a bit.

Notepad ++ is, AFAIK, an editor, it SHOULD (within reason) let you
write any text.

The double quote is needed due to the quoting rules of the language.
You want the regexp engine to see the characters leftp, dot, rightp,
backslash, one. But backslah is the scape character in strings ( in
many languages ), so you need to escape it too.

The same happens in, for example, C and Java. To put those five chars
in a string you need "(.)\\1". If you send "(.)\1" to a C compiler it
will build the string leftp, dot, rightp, SOH=(char)(1). It will
arrive to the backslash when parsing, see it is followed by a digit
less than 8, interpret it as an octal escape, and emit the SOH.

Francisco Olarte.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-01-24 18:41:10 Re: repeated characters in SQL
Previous Message rashapoo 2016-01-24 18:05:28 Re: repeated characters in SQL