postgresqlpostgresql-9.3postgresql-9.4postgresql-9.5

Postgres sql with regex expression


Trying to run sql : https://dbfiddle.uk/VlKz_7fg When I am running sql on fiddle its working fine, however when I am trying to run the same on my database it is throwing - ERROR: invalid regular expression: invalid character class

Can anyone please help how to resolve it..


Solution

  • You use the following character classes:

    In the listing of available classes for ver. 9.4 I see alpha but not word. See section 9.7.3.2. in https://www.postgresql.org/docs/9.4/functions-matching.html

    [[:word:]]
    Matches letters, numbers and underscores. Equivalent to \w or [a-zA-Z0-9_].

    So replace [[:word:]] with \w.

    See 9.4 based Fiddle