Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006

    Unanswered: function replace() and regex

    Hi all. I have this problem with replace() function in postgresql. I have some texts in db which contains html tags. When I search for occurence of word "table" in texts my results contains texts which has this word in html tags only. But I don't want search in html tags.
    I wrote select with WHERE clausule whiche contains replace function to fix this problem. But it doesn't work. Regular expression in replace function probably doesn't work.

    My select:
    SELECT * FROM textportions WHERE replace(text, '<[^>]*>', '') like '%table%'
    The questiuon is: Is replace() function working with regex??
    Or what can I do to solve my problem??

    Thanks for all.

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    According to the manual

    it does not support regular expressions.

    substring() does support regex so maybe you can use that.


    Just discovered that PG does have a regexp_replace() function.

    You might also be able to use the posix regex comparator to find those entries instead of using regexp_replace(). This is also described in the above link

    Last edited by shammat; 02-06-06 at 17:13.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts