RegExp[].Length is a new property that returns the length of a submatch.

[GB.PCRE]
* NEW: RegExp[].Length is a new property that returns the length of a submatch.
This commit is contained in:
Benoît Minisini 2023-10-28 02:00:48 +02:00
parent ed7a2c7807
commit 865002c06c
2 changed files with 15 additions and 0 deletions

View file

@ -349,6 +349,12 @@ BEGIN_PROPERTY(RegExp_Submatch_Offset)
END_PROPERTY
BEGIN_PROPERTY(RegExp_Submatch_Length)
GB.ReturnInteger(THIS->ovector[2 * THIS->_submatch + 1] - THIS->ovector[2 * THIS->_submatch]);
END_PROPERTY
#include "regexp_common.h"
//---------------------------------------------------------------------------
@ -428,6 +434,7 @@ GB_DESC CRegexpSubmatchDesc[] =
GB_PROPERTY_READ("Offset", "i", RegExp_Submatch_Offset),
GB_PROPERTY_READ("Text", "s", RegExp_Submatch_Text),
GB_PROPERTY_READ("Length", "i", RegExp_Submatch_Length),
GB_END_DECLARE
};

View file

@ -320,6 +320,13 @@ BEGIN_PROPERTY(RegExp_Submatch_Offset)
END_PROPERTY
BEGIN_PROPERTY(RegExp_Submatch_Length)
GB.ReturnInteger(THIS->ovector ? THIS->ovector[2 * THIS->_submatch + 1] - THIS->ovector[2 * THIS->_submatch] : 0);
END_PROPERTY
#include "regexp_common.h"
//---------------------------------------------------------------------------
@ -396,6 +403,7 @@ GB_DESC CRegexpSubmatchDesc[] =
GB_PROPERTY_READ("Offset", "i", RegExp_Submatch_Offset),
GB_PROPERTY_READ("Text", "s", RegExp_Submatch_Text),
GB_PROPERTY_READ("Length", "i", RegExp_Submatch_Length),
GB_END_DECLARE
};