{"Entry":{"collection":"func","key":"regexp-replace","name":"regexp_replace","aliases":[],"metadata":{"changed_in":["8.3","15","18","19"],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"8.0","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"8.1"},{"descriptions_changed":true,"doc_overhaul":false,"from":"8.2","group_changed":null,"signatures":{"added":["regexp_replace ( string text, pattern text, replacement text [, flags text] ) → text"],"removed":["regexp_replace ( string text, pattern text, replacement text [,flags text] ) → text"]},"status":"changed","to":"8.3"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"},{"descriptions_changed":true,"doc_overhaul":false,"from":"14","group_changed":null,"signatures":{"added":["regexp_replace ( string text, pattern text, replacement text [, start integer ] [, flags text ] ) → text","regexp_replace ( string text, pattern text, replacement text, start integer, N integer [, flags text ] ) → text"],"removed":["regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text"]},"status":"changed","to":"15"},{"descriptions_changed":false,"doc_overhaul":false,"from":"17","group_changed":null,"signatures":{"added":["regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","regexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text"],"removed":["regexp_replace ( string text, pattern text, replacement text [, start integer ] [, flags text ] ) → text","regexp_replace ( string text, pattern text, replacement text, start integer, N integer [, flags text ] ) → text"]},"status":"changed","to":"18"},{"descriptions_changed":true,"doc_overhaul":false,"from":"18","group_changed":null,"signatures":{"added":["regexp_replace(string, pattern, replacement [, flags]) → text","regexp_replace(string, pattern, replacement, start [, N [, flags]]) → text"],"removed":[]},"status":"changed","to":"19"}],"content_hash":"4dfc9a9b34e654a58bd8f562eebfb354e07d6cfee236de2cdb175f620c4f29bf","first_version":"8.1","group":"string","group_label":"String Functions And Operators","groups":["string","matching"],"imported_at":"2026-09-27T17:57:28.397205+08:00","last_version":"20","name":"regexp_replace","name_key":"regexp_replace","position":3032,"present_in":["8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","signature_count":4,"slug":"regexp-replace","source_rev":"b7bd9cda","summary":"Replaces the substring that is the first match to the POSIX regular expression pattern, or all such matches if the g flag is used; see Section 9.7.3.1.7.","summary_zh":""}},"Definition":{"Collection":"func","Key":"regexp-replace","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"regexp-replace","SourceRevision":"b7bd9cda","Facts":{"description":"Replaces the substring that is the first match to the POSIX regular expression pattern, or all such matches if the g flag is used; see Section 9.7.3.","description_html":"Replaces the substring that is the first match to the POSIX regular expression \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or all such matches if the \u003ccode class=\"literal\"\u003eg\u003c/code\u003e flag is used; see \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e.","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","slug":"18"},"group":"string","group_label":"String Functions And Operators","lang":"en","layout":"table-new","pages":["functions-string.html"],"prose_only":false,"signatures":[{"description":"Replaces the substring that is the first match to the POSIX regular expression pattern, or all such matches if the g flag is used; see Section 9.7.3.","description_html":"Replaces the substring that is the first match to the POSIX regular expression \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or all such matches if the \u003ccode class=\"literal\"\u003eg\u003c/code\u003e flag is used; see \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"regexp_replace('Thomas', '.[mN]a.', 'M')","result":"ThM"}],"html":"\u003ccode class=\"function\"\u003eregexp_replace\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ereplacement\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eflags\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","zh_from":""},{"description":"Replaces the substring that is the N'th match to the POSIX regular expression pattern, or all such matches if N is zero, with the search beginning at the start'th character of string. If N is omitted, it defaults to 1. See Section 9.7.3.","description_html":"Replaces the substring that is the \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e'th match to the POSIX regular expression \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or all such matches if \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is zero, with the search beginning at the \u003cem class=\"parameter\"\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e'th character of \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is omitted, it defaults to 1. See \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"regexp_replace('Thomas', '.', 'X', 3, 2)","result":"ThoXas"},{"expr":"regexp_replace(string=\u003e'hello world', pattern=\u003e'l', replacement=\u003e'XX', start=\u003e1, \"N\"=\u003e2)","result":"helXXo world"}],"html":"\u003ccode class=\"function\"\u003eregexp_replace\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ereplacement\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eflags\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e\u003c/span\u003e ]\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"regexp-replace","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"regexp_replace","Summary":"替换第一个与 POSIX 正则表达式pattern匹配的子字符串，如果使用了g标志，则替换所有这样的匹配；参见第 9.7.3 节。","BodyHTML":"替换第一个与 POSIX 正则表达式\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串，如果使用了\u003ccode\u003eg\u003c/code\u003e标志，则替换所有这样的匹配；参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" rel=\"nofollow\"\u003e第 9.7.3 节\u003c/a\u003e。\u003cpre\u003eregexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text\u003c/pre\u003e替换第一个与 POSIX 正则表达式\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串，如果使用了\u003ccode\u003eg\u003c/code\u003e标志，则替换所有这样的匹配；参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" rel=\"nofollow\"\u003e第 9.7.3 节\u003c/a\u003e。\u003cpre\u003eregexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text\u003c/pre\u003e替换第\u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e个与 POSIX 正则表达式\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串；如果\u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e为零，则替换所有这样的匹配。搜索从\u003cem\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e的第\u003cem\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e个字符开始。如果省略\u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e，则默认为 1。参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" rel=\"nofollow\"\u003e第 9.7.3 节\u003c/a\u003e。","SourceRevision":"1b5ca64c","ContentHash":"42ec33aa8f86df7288786670c923e12effae92dbbbf9e7c470d63e914515c554","Payload":{"description_zh":"替换第一个与 POSIX 正则表达式pattern匹配的子字符串，如果使用了g标志，则替换所有这样的匹配；参见第 9.7.3 节。","description_zh_html":"替换第一个与 POSIX 正则表达式\u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串，如果使用了\u003ccode class=\"literal\"\u003eg\u003c/code\u003e标志，则替换所有这样的匹配；参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX正则表达式\"\u003e第 9.7.3 节\u003c/a\u003e。","signatures":[{"description_zh":"替换第一个与 POSIX 正则表达式pattern匹配的子字符串，如果使用了g标志，则替换所有这样的匹配；参见第 9.7.3 节。","description_zh_html":"替换第一个与 POSIX 正则表达式\u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串，如果使用了\u003ccode class=\"literal\"\u003eg\u003c/code\u003e标志，则替换所有这样的匹配；参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX正则表达式\"\u003e第 9.7.3 节\u003c/a\u003e。","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","zh_from":"doc"},{"description_zh":"替换第N个与 POSIX 正则表达式pattern匹配的子字符串；如果N为零，则替换所有这样的匹配。搜索从string的第start个字符开始。如果省略N，则默认为 1。参见第 9.7.3 节。","description_zh_html":"替换第\u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e个与 POSIX 正则表达式\u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e匹配的子字符串；如果\u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e为零，则替换所有这样的匹配。搜索从\u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e的第\u003cem class=\"parameter\"\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e个字符开始。如果省略\u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e，则默认为 1。参见\u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX正则表达式\"\u003e第 9.7.3 节\u003c/a\u003e。","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"1b69ba2c7cdb6427f55d30fdf4b4faf37155173728699b8229ceff306f8df55d","Text":"regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","Returns":"text","Payload":{"description":"Replaces the substring that is the first match to the POSIX regular expression pattern, or all such matches if the g flag is used; see Section 9.7.3.","description_html":"Replaces the substring that is the first match to the POSIX regular expression \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or all such matches if the \u003ccode class=\"literal\"\u003eg\u003c/code\u003e flag is used; see \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"regexp_replace('Thomas', '.[mN]a.', 'M')","result":"ThM"}],"html":"\u003ccode class=\"function\"\u003eregexp_replace\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ereplacement\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eflags\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text [, flags text ] ) → text","zh_from":""}},{"Version":"18","Ordinal":1,"Hash":"9edf02faeb5cf2cd260bc1c7baf39622c1ebfddbf3f2d494de8ab0b8c43287c9","Text":"regexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text","Returns":"text","Payload":{"description":"Replaces the substring that is the N'th match to the POSIX regular expression pattern, or all such matches if N is zero, with the search beginning at the start'th character of string. If N is omitted, it defaults to 1. See Section 9.7.3.","description_html":"Replaces the substring that is the \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e'th match to the POSIX regular expression \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or all such matches if \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is zero, with the search beginning at the \u003cem class=\"parameter\"\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e'th character of \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is omitted, it defaults to 1. See \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e.","description_zh":"","description_zh_html":"","examples":[{"expr":"regexp_replace('Thomas', '.', 'X', 3, 2)","result":"ThoXas"},{"expr":"regexp_replace(string=\u003e'hello world', pattern=\u003e'l', replacement=\u003e'XX', start=\u003e1, \"N\"=\u003e2)","result":"helXXo world"}],"html":"\u003ccode class=\"function\"\u003eregexp_replace\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ereplacement\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003estart\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eflags\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003etext\u003c/code\u003e\u003c/span\u003e ]\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"regexp_replace ( string text, pattern text, replacement text, start integer [, N integer [, flags text ] ] ) → text","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
