[GB.PCRE]
* BUG: RegExp.Replace() now replaces once if the pattern starts with "^". git-svn-id: svn://localhost/gambas/trunk@6756 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
d5ef3c0e92
commit
b4dd31362a
1 changed files with 7 additions and 5 deletions
|
@ -393,18 +393,14 @@ BEGIN_METHOD(RegExp_Replace, GB_STRING subject; GB_STRING pattern; GB_STRING rep
|
|||
exec(&r, GB.StringLength(subject) - offset);
|
||||
|
||||
if (r.ovector[0] < 0)
|
||||
{
|
||||
result = GB.AddString(result, &subject[offset], GB.StringLength(subject) - offset);
|
||||
//fprintf(stderr, "result = %s\n", result);
|
||||
break;
|
||||
}
|
||||
|
||||
_subst_regexp = &r;
|
||||
|
||||
if (r.ovector[0] > 0)
|
||||
{
|
||||
#if DEBUG_REPLACE
|
||||
fprintf(stderr, "add: (%d) %.*s\n", lp, r.ovector[i * 2] - lp, &r.subject[lp]);
|
||||
fprintf(stderr, "add: (%d) %.*s\n", r.ovector[0], r.ovector[0], r.subject);
|
||||
#endif
|
||||
result = GB.AddString(result, r.subject, r.ovector[0]);
|
||||
#if DEBUG_REPLACE
|
||||
|
@ -422,8 +418,14 @@ BEGIN_METHOD(RegExp_Replace, GB_STRING subject; GB_STRING pattern; GB_STRING rep
|
|||
#endif
|
||||
|
||||
offset += r.ovector[1];
|
||||
|
||||
if (*r.pattern == '^')
|
||||
break;
|
||||
}
|
||||
|
||||
if (offset < LENGTH(subject))
|
||||
result = GB.AddString(result, &subject[offset], LENGTH(subject) - offset);
|
||||
|
||||
_subst_regexp = NULL;
|
||||
|
||||
GB.FreeStringLater(result);
|
||||
|
|
Loading…
Reference in a new issue