Postgres SQL replaces the matching string

Source: Internet
Author: User
Update contentitem Set "content" = regexp_replace ("content", '(\ n)', '<br/> ') Where Isdeleted = false And "content "~ * '\ N ';

 

The main knowledge points used are:

Regular Expression matching:

Operator Description Example
~ Match regular expressions, case sensitive 'Thomas '~ '. * Thomas .*'
~ * Match regular expression, case-insensitive 'Thomas '~ * '. * Thomas .*'
!~ Does not match regular expression, case-sensitive 'Thomas '!~ '. * Thomas .*'
!~ * Does not match the regular expression. It is case-insensitive. 'Thomas '!~ * '. * Vadim .*'

 

Function: regexp_replace (string text, pattern text, replacement text [, flags text])
Note: If no match exists Pattern   Sub-string, then Returns the unmodified Source   String. If a match exists Source   The corresponding substring in the string will be Replacement   Replace the string. Replacement   The string can contain \ N , This In N   Yes 1   To 9 , It indicates N   Items The section of the arc subexpression is inserted at this position and can contain \&   Indicates that the entire pattern should be inserted. String. For example If you need to put a text Reverse Oblique Bar on Replace the text Write \\ .

Example: regexp_replace ('thomAs ','. [Mn]A. ', 'M')= THM

 

Function: Replace (string text, from text, to text)
Note: replace all occurrences in string of substring fr OM with substring to replace a substring of a character Into another substring
Example: ('abcd E Fabcdef ', 'CD ' , 'Xx') = abxxefabx XeF

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.