version 5.0.0_beta

integrate PIRegularExpression into PIString and PIDir
add piliterals_regularexpression.h for ""_regex and ""_glob literals
This commit is contained in:
2025-08-13 18:48:01 +03:00
parent 7a6936ccd9
commit b6c5d65a8d
9 changed files with 158 additions and 57 deletions

View File

@@ -998,6 +998,11 @@ PIStringList PIString::split(const PIString & delim) const {
}
bool PIString::contains(const PIRegularExpression & regexp) const {
return regexp.match(const_cast<PIString &>(*this)).hasMatch();
}
//! \~\details
//! \~\code
//! PIString s("012345012345");
@@ -1033,6 +1038,11 @@ int PIString::find(const PIString & str, const int start) const {
}
int PIString::find(const PIRegularExpression & regexp, const int start) const {
return regexp.match(const_cast<PIString &>(*this), start).matchedStart();
}
//! \~\details
//! \~\code
//! piCout << PIString("1.str").findAny(".,:"); // 1
@@ -1090,6 +1100,16 @@ int PIString::findLast(const PIString & str, const int start) const {
}
int PIString::findLast(const PIRegularExpression & regexp, const int start) const {
auto m = regexp.match(const_cast<PIString &>(*this), start);
int ret = m.matchedStart();
while (m.next()) {
ret = m.matchedStart();
}
return ret;
}
//! \~\details
//! \~\code
//! piCout << PIString(".str.0").findAnyLast(".,:"); // 4