diff --git a/uppsrc/plugin/pcre/RegExp.cpp b/uppsrc/plugin/pcre/RegExp.cpp index 7f2523e1a..a975b4278 100644 --- a/uppsrc/plugin/pcre/RegExp.cpp +++ b/uppsrc/plugin/pcre/RegExp.cpp @@ -162,6 +162,27 @@ void RegExp::GetMatchPos(int i, int& iPosStart, int& iPosAfterEnd) iPosAfterEnd = pos[i + 1]; } +int RegExp::GetOffset() const +{ + return rc > 0 ? pos[0] : -1; +} + +int RegExp::GetLength() const +{ + return rc > 0 ? pos[1] - pos[0] : -1; +} + +int RegExp::GetSubOffset(int i) const +{ + ASSERT(i < rc - 1); + return pos[2 * i + 2]; +} + +int RegExp::GetSubLength(int i) const +{ + return pos[2 * i + 3] - pos[2 * i + 2]; +} + bool RegExp::ReplacePos(String& t, int p, int q, const String& r) { if(p>=0 && q<=t.GetLength() && q>p){ diff --git a/uppsrc/plugin/pcre/RegExp.h b/uppsrc/plugin/pcre/RegExp.h index a4e33da4a..8e6662eba 100644 --- a/uppsrc/plugin/pcre/RegExp.h +++ b/uppsrc/plugin/pcre/RegExp.h @@ -90,6 +90,11 @@ public: int GetCount(); String GetString(int i); void GetMatchPos(int i, int& iPosStart, int& iPosAfterEnd); + + int GetOffset() const; + int GetLength() const; + int GetSubOffset(int i) const; + int GetSubLength(int i) const; int Replace(String& t, const Vector& rv, bool backref=false); int Replace(String& t, const String& r, bool backref=false);