diff options
author | Bruce Momjian | 2005-07-10 04:54:33 +0000 |
---|---|---|
committer | Bruce Momjian | 2005-07-10 04:54:33 +0000 |
commit | ba78293516eb521ff282aeb2aad8f18eee9f7add (patch) | |
tree | 727a764c7b1e6fc019d4343a8ae795a9384cf913 /src/backend/regex/regexec.c | |
parent | 1c2577907fdf8ed98afae2b19411ad1b25044914 (diff) |
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.
Atsushi Ogawa
Diffstat (limited to 'src/backend/regex/regexec.c')
-rw-r--r-- | src/backend/regex/regexec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index 808f894711..eb5807545e 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -110,6 +110,7 @@ struct vars regmatch_t *pmatch; rm_detail_t *details; chr *start; /* start of string */ + chr *search_start; /* search start of string */ chr *stop; /* just past end of string */ int err; /* error code if any (0 none) */ regoff_t *mem; /* memory vector for backtracking */ @@ -168,6 +169,7 @@ int pg_regexec(regex_t *re, const chr *string, size_t len, + size_t search_start, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], @@ -219,6 +221,7 @@ pg_regexec(regex_t *re, v->pmatch = pmatch; v->details = details; v->start = (chr *) string; + v->search_start = (chr *) string + search_start; v->stop = (chr *) string + len; v->err = 0; if (backref) @@ -288,7 +291,8 @@ find(struct vars * v, NOERR(); MDEBUG(("\nsearch at %ld\n", LOFF(v->start))); cold = NULL; - close = shortest(v, s, v->start, v->start, v->stop, &cold, (int *) NULL); + close = shortest(v, s, v->search_start, v->search_start, v->stop, + &cold, (int *) NULL); freedfa(s); NOERR(); if (v->g->cflags & REG_EXPECT) @@ -415,7 +419,7 @@ cfindloop(struct vars * v, assert(d != NULL && s != NULL); cold = NULL; - close = v->start; + close = v->search_start; do { MDEBUG(("\ncsearch at %ld\n", LOFF(close))); |