Add function to the String API for locating the last instance of a substring in a string.
git-svn-id: http://yate.null.ro/svn/yate/trunk@5916 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
f9e6470a90
commit
a9fa6b1bd0
|
@ -1050,6 +1050,14 @@ int String::rfind(char what) const
|
|||
return s ? s-m_string : -1;
|
||||
}
|
||||
|
||||
int String::rfind(const char* what) const
|
||||
{
|
||||
int ret = -1;
|
||||
for (int pos = -1; (pos = find(what,pos + 1)) >= 0;)
|
||||
ret = pos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool String::startsWith(const char* what, bool wordBreak, bool caseInsensitive) const
|
||||
{
|
||||
if (!(m_string && what && *what))
|
||||
|
|
|
@ -2445,6 +2445,13 @@ public:
|
|||
*/
|
||||
int rfind(char what) const;
|
||||
|
||||
/**
|
||||
* Locate the last instance of a substring in the string
|
||||
* @param what Substring to search for
|
||||
* @return Offset of substring or -1 if not found
|
||||
*/
|
||||
int rfind(const char* what) const;
|
||||
|
||||
/**
|
||||
* Checks if the string starts with a substring
|
||||
* @param what Substring to search for
|
||||
|
|
Loading…
Reference in New Issue