Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:56:48+00:00 2026-06-15T00:56:48+00:00

Recently, we have changed from MySQL to PostgreSQL. Most of the queries have been

  • 0

Recently, we have changed from MySQL to PostgreSQL. Most of the queries have been translated except for the ones with the Mysql ‘REGEXP’ keyword:

MySQL (prepared statement):
SELECT * FROM table WHERE ? REGEXP identifier;

We have a ‘table’, and one of the columns is called ‘identifier’. This ‘identifier’ column contains the actual regular expression pattern.

So, instead of ‘hard-coding’ the regexp pattern in the query, it looks-up the identifier column for the pattern.

In Postgresql, we need to use the ‘~’ keyword instead of the ‘REGEXP’ one (which is MySQL only), but with Postgresql I cannot seem to extract the pattern from a column.

I’ve tried following queries without success:

SELECT * FROM table WHERE 'test' ~ "identifier";
ERROR:  invalid regular expression: parentheses () not balanced


SELECT * FROM table WHERE "identifier" ~ 'test';
-> no results

for testing purposes I created a number of records where the “identifier” column contains ‘.*’ as value (regular expression for match everything), but still I do not get the appropriate result.

Help is very much welcome, thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:56:49+00:00Added an answer on June 15, 2026 at 12:56 am

    Maybe the problem is in one of the regexp strings? (As the error string says)

    I’ve tested

    SELECT *
    FROM table1 t
    WHERE 'cat' ~ t.reg;
    

    And it works for me. Here is my SQL Fiddle. http://sqlfiddle.com/#!12/f245c/3

    The problem can be in different regexp interpretation. Details about postgresql regexp here http://www.postgresql.org/docs/current/static/functions-matching.html

    UPD Also read http://www.postgresql.org/docs/current/interactive/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS for detail about postgresql strings. You need this to write regexp correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have migrated my project from SQLServer 2000 to MySQL 5.2 using MySQL
I have a form on an ASP.NET MVC site which I've recently changed from
I have recently changed from using the cassini development server to IIS 7.5 express,
I have recently changed from web site model to a web application model .
I have recently changed to ubuntu from windows and am having difficulty with the
I have recently changed my web app to create a database connection per command
I was recently trying to re-install the fos:userbundle and noticed the docs have changed.
I recently changed my password and have to change my maven settings.xml file to
I recently have just been able to populate my core data DB. I have
I recently have convert my project from VB6 to VB.NET2008, after the convert here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.