Skip to content

Commit 7351b16

Browse files
committed
#51 - Implement method CppStringT::strip()
Completed.
1 parent 9845bab commit 7351b16

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,26 @@ namespace pcs // i.e. "pythonic c++ strings"
13051305
}
13061306

13071307

1308+
//--- strip() -----------------------------------------
1309+
/** \brief Returns a copy of the string with the leading and trailing characters removed.
1310+
*
1311+
* The passed string specifies the set of characters to be removed.
1312+
* The chars argument is not a prefix; rather, all combinations of
1313+
* its values are stripped.
1314+
*/
1315+
inline CppStringT strip(const CppStringT& prefix) const noexcept
1316+
{
1317+
return this->rstrip(prefix).lstrip(prefix);
1318+
}
1319+
1320+
/** \brief Returns a copy of the string with the leading and trailing whitespaces removed. */
1321+
inline CppStringT strip() const noexcept
1322+
{
1323+
return this->rstrip().lstrip();
1324+
}
1325+
1326+
1327+
13081328
//--- title() -----------------------------------------
13091329
/** \brief Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase. */
13101330
inline CppStringT title() const noexcept

0 commit comments

Comments
 (0)