| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. |
| 7 |
| 8 library services.src.correction.strings; |
| 9 |
| 10 |
| 11 String capitalize(String str) { |
| 12 if (isEmpty(str)) { |
| 13 return str; |
| 14 } |
| 15 return str.substring(0, 1).toUpperCase() + str.substring(1); |
| 16 } |
| 17 |
| 18 bool isEmpty(String str) { |
| 19 return str == null || str.isEmpty; |
| 20 } |
| 21 |
| 22 bool isLetter(int c) { |
| 23 return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); |
| 24 } |
| 25 |
| 26 bool isSpace(int c) => c == 0x20 || c == 0x09; |
| 27 |
| 28 bool isUpperCase(int c) { |
| 29 return c >= 0x41 && c <= 0x5A; |
| 30 } |
| 31 |
| 32 bool isWhitespace(int c) { |
| 33 return isSpace(c) || c == 0x0D || c == 0x0A; |
| 34 } |
| 35 |
| 36 String join(Iterable iter, [String separator = ' ', int start = 0, int end = |
| 37 -1]) { |
| 38 if (start != 0) { |
| 39 iter = iter.skip(start); |
| 40 } |
| 41 if (end != -1) { |
| 42 iter = iter.take(end - start); |
| 43 } |
| 44 return iter.join(separator); |
| 45 } |
| 46 |
| 47 String remove(String str, String remove) { |
| 48 if (isEmpty(str) || isEmpty(remove)) { |
| 49 return str; |
| 50 } |
| 51 return str.replaceAll(remove, ''); |
| 52 } |
| 53 |
| 54 String removeStart(String str, String remove) { |
| 55 if (isEmpty(str) || isEmpty(remove)) { |
| 56 return str; |
| 57 } |
| 58 if (str.startsWith(remove)) { |
| 59 return str.substring(remove.length); |
| 60 } |
| 61 return str; |
| 62 } |
| 63 |
| 64 String repeat(String s, int n) { |
| 65 StringBuffer sb = new StringBuffer(); |
| 66 for (int i = 0; i < n; i++) { |
| 67 sb.write(s); |
| 68 } |
| 69 return sb.toString(); |
| 70 } |
| 71 |
| 72 List<String> split(String s, [String pattern = '']) { |
| 73 return s.split(pattern); |
| 74 } |
| 75 |
| 76 List<String> splitByWholeSeparatorPreserveAllTokens(String s, String pattern) { |
| 77 return s.split(pattern); |
| 78 } |
| OLD | NEW |