| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library services.src.correction.strings; | 5 library services.src.correction.strings; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * "$" | 10 * "$" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool isDigit(int c) { | 196 bool isDigit(int c) { |
| 197 return c >= 0x30 && c <= 0x39; | 197 return c >= 0x30 && c <= 0x39; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool isEmpty(String str) { | 200 bool isEmpty(String str) { |
| 201 return str == null || str.isEmpty; | 201 return str == null || str.isEmpty; |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool isEOL(int c) { |
| 205 return c == 0x0D || c == 0x0A; |
| 206 } |
| 207 |
| 204 bool isLetter(int c) { | 208 bool isLetter(int c) { |
| 205 return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); | 209 return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); |
| 206 } | 210 } |
| 207 | 211 |
| 208 bool isLetterOrDigit(int c) { | 212 bool isLetterOrDigit(int c) { |
| 209 return isLetter(c) || isDigit(c); | 213 return isLetter(c) || isDigit(c); |
| 210 } | 214 } |
| 211 | 215 |
| 212 bool isLowerCase(int c) { | 216 bool isLowerCase(int c) { |
| 213 return c >= 0x61 && c <= 0x7A; | 217 return c >= 0x61 && c <= 0x7A; |
| 214 } | 218 } |
| 215 | 219 |
| 216 bool isSpace(int c) => c == 0x20 || c == 0x09; | 220 bool isSpace(int c) => c == 0x20 || c == 0x09; |
| 217 | 221 |
| 218 bool isUpperCase(int c) { | 222 bool isUpperCase(int c) { |
| 219 return c >= 0x41 && c <= 0x5A; | 223 return c >= 0x41 && c <= 0x5A; |
| 220 } | 224 } |
| 221 | 225 |
| 222 bool isWhitespace(int c) { | 226 bool isWhitespace(int c) { |
| 223 return isSpace(c) || c == 0x0D || c == 0x0A; | 227 return isSpace(c) || isEOL(c); |
| 224 } | 228 } |
| 225 | 229 |
| 226 String remove(String str, String remove) { | 230 String remove(String str, String remove) { |
| 227 if (isEmpty(str) || isEmpty(remove)) { | 231 if (isEmpty(str) || isEmpty(remove)) { |
| 228 return str; | 232 return str; |
| 229 } | 233 } |
| 230 return str.replaceAll(remove, ''); | 234 return str.replaceAll(remove, ''); |
| 231 } | 235 } |
| 232 | 236 |
| 233 String removeEnd(String str, String remove) { | 237 String removeEnd(String str, String remove) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 272 } |
| 269 if (isEmpty(separator)) { | 273 if (isEmpty(separator)) { |
| 270 return ''; | 274 return ''; |
| 271 } | 275 } |
| 272 int pos = str.lastIndexOf(separator); | 276 int pos = str.lastIndexOf(separator); |
| 273 if (pos == -1) { | 277 if (pos == -1) { |
| 274 return str; | 278 return str; |
| 275 } | 279 } |
| 276 return str.substring(pos + separator.length); | 280 return str.substring(pos + separator.length); |
| 277 } | 281 } |
| OLD | NEW |