String manipulation library
StringUtil.cpp@2:ea93cc1c113a, 2018-04-29 (annotated)
- Committer:
- tichise
- Date:
- Sun Apr 29 05:56:32 2018 +0000
- Revision:
- 2:ea93cc1c113a
- Parent:
- 1:5a7b4310d67c
fix header
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tichise | 0:28fdf43083f9 | 1 | #include "StringUtil.h" |
tichise | 0:28fdf43083f9 | 2 | #include "mbed.h" |
tichise | 0:28fdf43083f9 | 3 | |
tichise | 0:28fdf43083f9 | 4 | StringUtil::StringUtil() { |
tichise | 0:28fdf43083f9 | 5 | } |
tichise | 0:28fdf43083f9 | 6 | |
tichise | 1:5a7b4310d67c | 7 | // 文字列textからstart_stringとend_stringで囲まれた部分を抽出する。 |
tichise | 1:5a7b4310d67c | 8 | string StringUtil::slice(string text, string startString, string endString) |
tichise | 0:28fdf43083f9 | 9 | { |
tichise | 1:5a7b4310d67c | 10 | int startPosition = text.find(startString); |
tichise | 1:5a7b4310d67c | 11 | int endPosition = text.rfind(endString); |
tichise | 1:5a7b4310d67c | 12 | return text.substr(startPosition + 1, endPosition - endPosition - 1); |
tichise | 0:28fdf43083f9 | 13 | } |