regexp_replace
I made the patch that implements regexp_replace again.
The specification of this function is as follows.
regexp_replace(source text, pattern text, replacement text, [flags text])
returns text
Replace string that matches to regular expression in source text to
replacement text.
- pattern is regular expression pattern.
- replacement is replace string that can use '\1'-'\9', and '\&'.
'\1'-'\9': back reference to the n'th subexpression.
'\&' : entire matched string.
- flags can use the following values:
g: global (replace all)
i: ignore case
When the flags is not specified, case sensitive, replace the first
instance only.
regards,
--- Atsushi Ogawa
Attachments:
regexp_replace.patchapplication/octet-stream; name=regexp_replace.patchDownload+460-57
I'm very glad to see this. But is a nicer name possible? To perl
programmers at least, "substitute" should make sense.
cheers
andrew
Atsushi Ogawa wrote:
Show quoted text
I made the patch that implements regexp_replace again.
The specification of this function is as follows.regexp_replace(source text, pattern text, replacement text, [flags text])
returns textReplace string that matches to regular expression in source text to
replacement text.- pattern is regular expression pattern.
- replacement is replace string that can use '\1'-'\9', and '\&'.
'\1'-'\9': back reference to the n'th subexpression.
'\&' : entire matched string.
- flags can use the following values:
g: global (replace all)
i: ignore case
When the flags is not specified, case sensitive, replace the first
instance only.regards,
--- Atsushi Ogawa------------------------------------------------------------------------
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Andrew Dunstan wrote:
I'm very glad to see this. But is a nicer name possible? To perl
programmers at least, "substitute" should make sense.
What is the matter with replace? We already have replace:
test=> \df replace
List of functions
Schema | Name | Result data type | Argument data types
------------+---------+------------------+---------------------
pg_catalog | replace | text | text, text, text
test=> \df replace
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian wrote:
Andrew Dunstan wrote:
I'm very glad to see this. But is a nicer name possible? To perl
programmers at least, "substitute" should make sense.What is the matter with replace? We already have replace:
test=> \df replace
List of functions
Schema | Name | Result data type | Argument data types
------------+---------+------------------+---------------------
pg_catalog | replace | text | text, text, text
I think that regexp_replace is a good name. It is easy to understand.
regards,
--- Atsushi Ogawa
Atsushi Ogawa wrote:
I think that regexp_replace is a good name. It is easy to understand.
I'll go with the flow.
cheers
andrew
pg_catalog | replace | text | text, text, text
I think that regexp_replace is a good name. It is easy to understand.
regards,
I prefere this name too
Regards
Pavel Stehule
I have applied your patch, with slight adjustments in spacing and
documentation.
Patch applied. Thanks.
---------------------------------------------------------------------------
Atsushi Ogawa wrote:
I made the patch that implements regexp_replace again.
The specification of this function is as follows.regexp_replace(source text, pattern text, replacement text, [flags text])
returns textReplace string that matches to regular expression in source text to
replacement text.- pattern is regular expression pattern.
- replacement is replace string that can use '\1'-'\9', and '\&'.
'\1'-'\9': back reference to the n'th subexpression.
'\&' : entire matched string.
- flags can use the following values:
g: global (replace all)
i: ignore case
When the flags is not specified, case sensitive, replace the first
instance only.regards,
--- Atsushi Ogawa
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Attachments:
/bjm/difftext/plainDownload+450-63
The change below has broken tsearch2. See for example
http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=shrew&dt=2005-07-10%2015:02:01
cheers
andrew
Bruce Momjian wrote:
I have applied your patch, with slight adjustments in spacing and
documentation.Patch applied. Thanks.
[snip]
Show quoted text
Index: src/include/regex/regex.h =================================================================== RCS file: /cvsroot/pgsql/src/include/regex/regex.h,v retrieving revision 1.26 diff -c -c -r1.26 regex.h *** src/include/regex/regex.h 29 Nov 2003 22:41:10 -0000 1.26 --- src/include/regex/regex.h 10 Jul 2005 04:52:51 -0000 *************** *** 163,169 **** * the prototypes for exported functions */ extern int pg_regcomp(regex_t *, const pg_wchar *, size_t, int); ! extern int pg_regexec(regex_t *, const pg_wchar *, size_t, rm_detail_t *, size_t, regmatch_t[], int); extern void pg_regfree(regex_t *); extern size_t pg_regerror(int, const regex_t *, char *, size_t);--- 163,169 ---- * the prototypes for exported functions */ extern int pg_regcomp(regex_t *, const pg_wchar *, size_t, int); ! extern int pg_regexec(regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t *, size_t, regmatch_t[], int); extern void pg_regfree(regex_t *); extern size_t pg_regerror(int, const regex_t *, char *, size_t);
Bruce Momjian wrote:
I have applied your patch, with slight adjustments in spacing and
documentation.Patch applied. Thanks.
Thank you for applying patch.
An attached patch is a small additional improvement.
This patch use appendStringInfoText instead of appendStringInfoString.
There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
executed by text type. This can be reduced by appendStringInfoText.
regards,
Atsushi Ogawa
Attachments:
varlena.patchapplication/octet-stream; name=varlena.patchDownload+10-10
Patch applied. Thanks.
---------------------------------------------------------------------------
Atsushi Ogawa wrote:
Bruce Momjian wrote:
I have applied your patch, with slight adjustments in spacing and
documentation.Patch applied. Thanks.
Thank you for applying patch.
An attached patch is a small additional improvement.This patch use appendStringInfoText instead of appendStringInfoString.
There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
executed by text type. This can be reduced by appendStringInfoText.regards,
Atsushi Ogawa
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073