--- parser3/src/include/pa_string.h 2026/10/13 20:02:00 1.244 +++ parser3/src/include/pa_string.h 2026/11/03 12:25:52 1.246 @@ -8,7 +8,7 @@ #ifndef PA_STRING_H #define PA_STRING_H -#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.244 2026/10/13 20:02:00 moko Exp $" +#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.246 2026/11/03 12:25:52 moko Exp $" // includes #include "pa_types.h" @@ -495,6 +495,9 @@ public: return CORD_rchr(body, right, c); } + /// position of the last @a substr starting at or before @a offset, -1 means "not found" + size_t rpos(const Body substr, size_t offset) const; + size_t strrpbrk(const char* chars, size_t left, size_t right) const; size_t rskipchars(const char* chars, size_t left, size_t right) const; @@ -656,7 +659,9 @@ public: /// extracts [start, finish) piece of string String& mid(size_t substr_begin, size_t substr_end) const; - String& mid(Charset& charset, size_t from, size_t to, size_t helper_length=0) const; + String& mid(Charset& charset, size_t from, size_t to) const; + /// extracts the last n characters + const String& right(Charset& charset, size_t n) const; /// return position of substr in string, -1 means "not found" [const char* version] size_t pos(const char* substr, size_t this_offset=0) const { return body.pos(substr, this_offset); } @@ -667,6 +672,7 @@ public: size_t pos(const Body substr, size_t this_offset, Language lang) const; size_t pos(const String& substr, size_t this_offset, Language lang) const; size_t pos(Charset& charset, const String& substr, size_t this_offset=0, Language lang=L_UNSPECIFIED) const; + size_t rpos(Charset& charset, const String& substr, size_t this_offset) const; /// true if the characters from offset to offset+length are of lang or a cleaner one bool check_lang(Language lang, size_t offset, size_t length) const { return langs.check_lang(lang, offset, length); }