summaryrefslogtreecommitdiff
path: root/core/java/android/text/TextUtils.java
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2018-06-27 08:40:26 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-06-27 08:40:26 -0700
commit13b96fc1a13f1ffda38a3a80eff33acb6ec706f5 (patch)
treec05cbd6b4cfe4e9ea46e5883d400d6157d194caa /core/java/android/text/TextUtils.java
parent796fec2b9984c1500474d50df28099f7c16c1f35 (diff)
parente4449497ed9c6cc6f3a225bd1cf8f817cbe54ccc (diff)
Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28." am: b5f35aeaf3 am: 5442964205
am: e4449497ed Change-Id: I3bbb854c61f476caaef20eeae2bbcc9473c49469
Diffstat (limited to 'core/java/android/text/TextUtils.java')
-rw-r--r--core/java/android/text/TextUtils.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index a0daa0783618..6b2f80241df3 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -351,8 +351,16 @@ public class TextUtils {
}
/**
- * String.split() returns [''] when the string to be split is empty. This returns []. This does
- * not remove any empty strings from the result. For example split("a,", "," ) returns {"a", ""}.
+ *
+ * This method yields the same result as {@code text.split(expression, -1)} except that if
+ * {@code text.isEmpty()} then this method returns an empty array whereas
+ * {@code "".split(expression, -1)} would have returned an array with a single {@code ""}.
+ *
+ * The {@code -1} means that trailing empty Strings are not removed from the result; for
+ * example split("a,", "," ) returns {"a", ""}. Note that whether a leading zero-width match
+ * can result in a leading {@code ""} depends on whether your app
+ * {@link android.content.pm.ApplicationInfo#targetSdkVersion targets an SDK version}
+ * {@code <= 28}; see {@link Pattern#split(CharSequence, int)}.
*
* @param text the string to split
* @param expression the regular expression to match
@@ -369,8 +377,16 @@ public class TextUtils {
}
/**
- * Splits a string on a pattern. String.split() returns [''] when the string to be
- * split is empty. This returns []. This does not remove any empty strings from the result.
+ * Splits a string on a pattern. This method yields the same result as
+ * {@code pattern.split(text, -1)} except that if {@code text.isEmpty()} then this method
+ * returns an empty array whereas {@code pattern.split("", -1)} would have returned an array
+ * with a single {@code ""}.
+ *
+ * The {@code -1} means that trailing empty Strings are not removed from the result;
+ * Note that whether a leading zero-width match can result in a leading {@code ""} depends
+ * on whether your app {@link android.content.pm.ApplicationInfo#targetSdkVersion targets
+ * an SDK version} {@code <= 28}; see {@link Pattern#split(CharSequence, int)}.
+ *
* @param text the string to split
* @param pattern the regular expression to match
* @return an array of strings. The array will be empty if text is empty