From 309000f8277bf859092737a94071a2932c3ff34f Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 7 Aug 2006 19:46:47 +0000 Subject: [PATCH] Added startsWith(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4301 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/StringUtil.as | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index 73603c523..b73a6effa 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -34,6 +34,15 @@ public class StringUtil return (startDex >= 0) && (str.indexOf(substr, startDex) >= 0); } + /** + * Does the specified string start with the specified substring. + */ + public static function startsWith (str :String, substr :String) :Boolean + { + // just check once if it's at the beginning + return (str.lastIndexOf(substr, 0) == 0); + } + /** * Utility function that strips whitespace from the ends of a String. */