diff options
author | Tianyi Liang <tianyi-liang@uiowa.edu> | 2013-12-26 17:18:26 -0600 |
---|---|---|
committer | Tianyi Liang <tianyi-liang@uiowa.edu> | 2013-12-26 17:18:26 -0600 |
commit | cac85606876d4f0be1c6c54172f7509ce54cdcb5 (patch) | |
tree | b25e27922f6039f5ec1c5e600932bd497b4f273e /src/util/regexp.h | |
parent | 97b04f18011a56e11fc5057b304fff9e9ab4e753 (diff) |
new functions in strings
Diffstat (limited to 'src/util/regexp.h')
-rw-r--r-- | src/util/regexp.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util/regexp.h b/src/util/regexp.h index 3a8fc7170..3f9df6aaf 100644 --- a/src/util/regexp.h +++ b/src/util/regexp.h @@ -183,6 +183,25 @@ public: return true; } + std::size_t find(const String &y) const { + if(y.d_str.size() == 0) return 0; + if(d_str.size() == 0) return std::string::npos; + std::size_t ret = std::string::npos; + for(int i = 0; i <= (int) d_str.size() - (int) y.d_str.size(); i++) { + if(d_str[i] == y.d_str[0]) { + std::size_t j=0; + for(; j<y.d_str.size(); j++) { + if(d_str[i+j] != y.d_str[j]) break; + } + if(j == y.d_str.size()) { + ret = (std::size_t) i; + break; + } + } + } + return ret; + } + String substr(unsigned i) const { std::vector<unsigned int> ret_vec; std::vector<unsigned int>::const_iterator itr = d_str.begin() + i; |