diff --git a/gb.pcre/src/regexp.c b/gb.pcre/src/regexp.c index c9bfa4343..4e4e4db0c 100644 --- a/gb.pcre/src/regexp.c +++ b/gb.pcre/src/regexp.c @@ -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 }; diff --git a/gb.pcre/src/regexp2.c b/gb.pcre/src/regexp2.c index 35223bc43..b99ace349 100644 --- a/gb.pcre/src/regexp2.c +++ b/gb.pcre/src/regexp2.c @@ -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 };