diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2017-10-27 23:16:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-27 23:16:38 -0500 |
commit | 675e82e32a34911163f9de0e6389eb107be5b0f1 (patch) | |
tree | a3215999b2f1550325b77d19e14a61793dafce35 /src/util/regexp.cpp | |
parent | 1fe3247a0bf4b806f99c161dcc9c6644aabb38c1 (diff) |
Improve strings rewriter for contains (#1207)
* Work on rewriter for string contains.
* Add rewrites that mix str.to.int and str.contains. Documentation, add regression.
* Minor
* Minor
* Address review, add a few TODOs. Improve some non-digit -> not is number.
* Fix
* Simplify.
* Clang format, minor fixing of comments.
Diffstat (limited to 'src/util/regexp.cpp')
-rw-r--r-- | src/util/regexp.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp index 681b574a3..d93c5426e 100644 --- a/src/util/regexp.cpp +++ b/src/util/regexp.cpp @@ -357,14 +357,20 @@ bool String::isNumber() const { return false; } for (unsigned character : d_str) { - unsigned char c = convertUnsignedIntToChar(character); - if (c < '0' || c > '9') { + if (!isDigit(character)) + { return false; } } return true; } +bool String::isDigit(unsigned character) +{ + unsigned char c = convertUnsignedIntToChar(character); + return c >= '0' && c <= '9'; +} + int String::toNumber() const { if (isNumber()) { int ret = 0; |