As someone said, it's not easy in general, since you can embed various perlisms into Perl regexes that POSIX regexes have no way of knowing about (lacking a perl interpreter).

A different approach would be to use Perl as a server-side language on Postgres. This page tells you how: http://www.oreillynet.com/pub/a/databases/2005/11/10/using-perl-in-postgresql.html

Their example is:

postgres$ createlang plperlu mydb
A Simple Example

The easy way to show how to use PL/Perl is to create a very simple function; one that would be a lot harder to do otherwise. Suppose that you want to test if a given piece of text is a palindrome (a word that reads the same backwards as forwards), disregarding white space and the case of the letters. Here's a piece of SQL to define the function:

create function palindrome(text) returns boolean language plperl immutable as ' my $arg = shift; my ($canonical = lc $arg) =~ s/\s+//g; return ($canonical eq reverse $canonical) ? "true" : "false"; ';
Given this function, you can write SQL like:
select name, region, country, population from towns where palindrome(name);

In reply to Re: Perl regex to POSIX by PreferredUserName
in thread Perl regex to POSIX by Sifmole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.