Re: What's wrong with this regexp?

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: What's wrong with this regexp?
Date: 2009-10-10 22:30:50
Message-ID: m33a5qc25h.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nick <nboutelier(at)gmail(dot)com> wrote:

> SELECT TRUE WHERE '/steps/?step=10' ~ '^\/steps\/\?step=10$'

> Im guessing its an escape issue, but where am I going wrong?

You need to double-escape the question mark: Once for the
string literal, once for the regular expression (and you do
not need to escape the slashes). This gives:

| tim=# SELECT TRUE WHERE '/steps/?step=10' ~ E'^/steps/\\?step=10$';
| bool
| ------
| t
| (1 Zeile)

| tim=#

Tim

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Randal L. Schwartz 2009-10-10 22:41:27 Re: What's wrong with this regexp?
Previous Message Raymond O'Donnell 2009-10-10 21:37:07 Re: Prepared statements with a variable number of parameters