selenium-webdriver
Version:
The official WebDriver JavaScript bindings from the Selenium project
122 lines (108 loc) • 76.9 kB
HTML
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.string</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Namespace goog.string</h1><a class="source" href="source/lib/goog/string/string.js.src.html#l23">code »</a></header><section></section><section><h2>Enumerations</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="enum_goog_string_Unicode.html">goog.string.Unicode</a><dd>Common Unicode string characters.</dl></table></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="static-functions"><h2>Global Functions</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1041">code »</a><span class="member"><a name="goog.string.buildString">goog.string.buildString</a> <span class="args">( var_args )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Concatenates string expressions. This is useful
since some browsers are very inefficient when it comes to using plus to
concat strings. Be careful when using null and undefined here since
these will not be included in the result. If you need to represent these
be sure to cast the argument to a String first.
For example:
<pre>buildString('a', 'b', 'c', 'd') -> 'abcd'
buildString(null, undefined) -> ''
</pre></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>var_args: <code class="type">...*</code><dd>A list of strings to concatenate. If not a string,
it will be casted to one.</dl><tr><th>Returns<tr><td><dl>The concatenation of <code >var_args</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l239">code »</a><span class="member"><a name="goog.string.canonicalizeNewlines">goog.string.canonicalizeNewlines</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Replaces Windows and Mac new lines with unix style: \r or \r\n with \n.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to in which to canonicalize newlines.</dl><tr><th>Returns<tr><td><dl><code >str</code> A copy of {@code} with canonicalized newlines.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l329">code »</a><span class="member"><a name="goog.string.caseInsensitiveCompare">goog.string.caseInsensitiveCompare</a> <span class="args">( str1, str2 )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>A string comparator that ignores case.
-1 = str1 less than str2
0 = str1 equals str2
1 = str1 greater than str2</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str1: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to compare.<dt>str2: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to compare <code >str1</code> to.</dl><tr><th>Returns<tr><td><dl>The comparator result, as described above.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l79">code »</a><span class="member"><a name="goog.string.caseInsensitiveEndsWith">goog.string.caseInsensitiveEndsWith</a> <span class="args">( str, suffix )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Case-insensitive suffix-checker.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.<dt>suffix: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string to look for at the end of <code >str</code>.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> ends with <code >suffix</code> (ignoring
case).</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l92">code »</a><span class="member"><a name="goog.string.caseInsensitiveEquals">goog.string.caseInsensitiveEquals</a> <span class="args">( str1, str2 )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Case-insensitive equality checker.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str1: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>First string to check.<dt>str2: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Second string to check.</dl><tr><th>Returns<tr><td><dl>True if <code >str1</code> and <code >str2</code> are the same string,
ignoring case.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l66">code »</a><span class="member"><a name="goog.string.caseInsensitiveStartsWith">goog.string.caseInsensitiveStartsWith</a> <span class="args">( str, prefix )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Case-insensitive prefix-checker.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.<dt>prefix: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string to look for at the end of <code >str</code>.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> begins with <code >prefix</code> (ignoring
case).</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l274">code »</a><span class="member"><a name="goog.string.collapseBreakingSpaces">goog.string.collapseBreakingSpaces</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Removes the breaking spaces from the left and right of the string and
collapses the sequences of breaking spaces in the middle into single spaces.
The original and the result strings render the same way in HTML.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string in which to collapse spaces.</dl><tr><th>Returns<tr><td><dl>Copy of the string with normalized breaking spaces.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l127">code »</a><span class="member"><a name="goog.string.collapseWhitespace">goog.string.collapseWhitespace</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Converts multiple whitespace chars (spaces, non-breaking-spaces, new lines
and tabs) to a single space, and strips leading and trailing whitespace.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Input string.</dl><tr><th>Returns<tr><td><dl>A copy of <code >str</code> with collapsed whitespace.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1130">code »</a><span class="member"><a name="goog.string.compareElements_">goog.string.compareElements_</a> <span class="args">( left, right )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Compares elements of a version number.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>left: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>)</code><dd>An element from a version number.<dt>right: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>)</code><dd>An element from a version number.</dl><tr><th>Returns<tr><td><dl>1 if <code >left</code> is higher.
0 if arguments are equal.
-1 if <code >right</code> is higher.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1072">code »</a><span class="member"><a name="goog.string.compareVersions">goog.string.compareVersions</a> <span class="args">( version1, version2 )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Compares two version numbers.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>version1: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code><dd>Version of first item.<dt>version2: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code><dd>Version of second item.</dl><tr><th>Returns<tr><td><dl>1 if <code >version1</code> is higher.
0 if arguments are equal.
-1 if <code >version2</code> is higher.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l905">code »</a><span class="member"><a name="goog.string.contains">goog.string.contains</a> <span class="args">( s, ss )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks whether a string contains a given substring.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to test.<dt>ss: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The substring to test for.</dl><tr><th>Returns<tr><td><dl>True if <code >s</code> contains <code >ss</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l917">code »</a><span class="member"><a name="goog.string.countOf">goog.string.countOf</a> <span class="args">( s, ss )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Returns the non-overlapping occurrences of ss in s.
If either s or ss evalutes to false, then returns zero.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to look in.<dt>ss: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to look for.</dl><tr><th>Returns<tr><td><dl>Number of occurrences of ss in s.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1183">code »</a><span class="member"><a name="goog.string.createUniqueString">goog.string.createUniqueString</a> <span class="args">( )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Generates and returns a string which is unique in the current document.
This is useful, for example, to create unique IDs for DOM elements.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A unique id.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l53">code »</a><span class="member"><a name="goog.string.endsWith">goog.string.endsWith</a> <span class="args">( str, suffix )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Fast suffix-checker.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.<dt>suffix: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string to look for at the end of <code >str</code>.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> ends with <code >suffix</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l848">code »</a><span class="member"><a name="goog.string.escapeChar">goog.string.escapeChar</a> <span class="args">( c )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Takes a character and returns the escaped string for that character. For
example escapeChar(String.fromCharCode(15)) -> "\\x0E".</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>c: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The character to escape.</dl><tr><th>Returns<tr><td><dl>An escaped string representing <code >c</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l833">code »</a><span class="member"><a name="goog.string.escapeString">goog.string.escapeString</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Takes a string and returns the escaped string for that character.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to escape.</dl><tr><th>Returns<tr><td><dl>An escaped string representing <code >str</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1055">code »</a><span class="member"><a name="goog.string.getRandomString">goog.string.getRandomString</a> <span class="args">( )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Returns a string with at least 64-bits of randomness.
Doesn't trust Javascript's random function entirely. Uses a combination of
random and current timestamp, and then encodes the string in base-36 to
make it shorter.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A random string, e.g. sn1s7vb4gcic.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1159">code »</a><span class="member"><a name="goog.string.hashCode">goog.string.hashCode</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>String hash function similar to java.lang.String.hashCode().
The hash code for a string is computed as
s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
where s[i] is the ith character of the string and n is the length of
the string. We mod the result to make it between 0 (inclusive) and 2^32
(exclusive).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string.</dl><tr><th>Returns<tr><td><dl>Hash value for <code >str</code>, between 0 (inclusive) and 2^32
(exclusive). The empty string returns 0.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l492">code »</a><span class="member"><a name="goog.string.htmlEscape">goog.string.htmlEscape</a> <span class="args">( str, opt_isLikelyToContainHtmlChars )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Escape double quote '"' characters in addition to '&', '<', and '>' so that a
string can be included in an HTML tag attribute value within double quotes.
It should be noted that > doesn't need to be escaped for the HTML or XML to
be valid, but it has been decided to escape it for consistency with other
implementations.
NOTE(user):
HtmlEscape is often called during the generation of large blocks of HTML.
Using statics for the regular expressions and strings is an optimization
that can more than half the amount of time IE spends in this function for
large apps, since strings and regexes both contribute to GC allocations.
Testing for the presence of a character before escaping increases the number
of function calls, but actually provides a speed increase for the average
case -- since the average case often doesn't require the escaping of all 4
characters and indexOf() is much cheaper than replace().
The worst case does suffer slightly from the additional calls, therefore the
opt_isLikelyToContainHtmlChars option has been included for situations
where all 4 HTML entities are very likely to be present and need escaping.
Some benchmarks (times tended to fluctuate +-0.05ms):
FireFox IE6
(no chars / average (mix of cases) / all 4 chars)
no checks 0.13 / 0.22 / 0.22 0.23 / 0.53 / 0.80
indexOf 0.08 / 0.17 / 0.26 0.22 / 0.54 / 0.84
indexOf + re test 0.07 / 0.17 / 0.28 0.19 / 0.50 / 0.85
An additional advantage of checking if replace actually needs to be called
is a reduction in the number of object allocations, so as the size of the
application grows the difference between the various methods would increase.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>string to be escaped.<dt>opt_isLikelyToContainHtmlChars: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>Don't perform a check to see
if the character needs replacing - use this option if you expect each of
the characters to appear often. Leave false if you expect few html
characters to occur in your strings, such as if you are escaping HTML.</dl><tr><th>Returns<tr><td><dl>An escaped copy of <code >str</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l176">code »</a><span class="member"><a name="goog.string.isAlpha">goog.string.isAlpha</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string contains all letters.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>string to check.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> consists entirely of letters.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l197">code »</a><span class="member"><a name="goog.string.isAlphaNumeric">goog.string.isAlphaNumeric</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string contains only numbers or letters.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>string to check.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> is alphanumeric.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l166">code »</a><span class="member"><a name="goog.string.isBreakingWhitespace">goog.string.isBreakingWhitespace</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string is all breaking whitespace.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.</dl><tr><th>Returns<tr><td><dl>Whether the string is all breaking whitespace.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l140">code »</a><span class="member"><a name="goog.string.isEmpty">goog.string.isEmpty</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string is empty or contains only whitespaces.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> is empty or whitespace only.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l156">code »</a><span class="member"><a name="goog.string.isEmptySafe">goog.string.isEmptySafe</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string is null, undefined, empty or contains only whitespaces.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type">*</code><dd>The string to check.</dl><tr><th>Returns<tr><td><dl>True if<code >str</code> is null, undefined, empty, or
whitespace only.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1217">code »</a><span class="member"><a name="goog.string.isLowerCamelCase">goog.string.isLowerCamelCase</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Returns whether the given string is lower camel case (e.g. "isFooBar").
Note that this assumes the string is entirely letters.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>String to test.</dl><tr><th>Returns<tr><td><dl>Whether the string is lower camel case.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l187">code »</a><span class="member"><a name="goog.string.isNumeric">goog.string.isNumeric</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a string contains only numbers.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type">*</code><dd>string to check. If not a string, it will be
casted to one.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> is numeric.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l207">code »</a><span class="member"><a name="goog.string.isSpace">goog.string.isSpace</a> <span class="args">( ch )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a character is a space character.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ch: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Character to check.</dl><tr><th>Returns<tr><td><dl>True if {code ch} is a space.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l217">code »</a><span class="member"><a name="goog.string.isUnicodeChar">goog.string.isUnicodeChar</a> <span class="args">( ch )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Checks if a character is a valid unicode character.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ch: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Character to check.</dl><tr><th>Returns<tr><td><dl>True if {code ch} is a valid unicode character.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1231">code »</a><span class="member"><a name="goog.string.isUpperCamelCase">goog.string.isUpperCamelCase</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Returns whether the given string is upper camel case (e.g. "FooBarBaz").
Note that this assumes the string is entirely letters.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>String to test.</dl><tr><th>Returns<tr><td><dl>Whether the string is upper camel case.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1022">code »</a><span class="member"><a name="goog.string.makeSafe">goog.string.makeSafe</a> <span class="args">( obj )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Returns a string representation of the given object, with
null and undefined being returned as the empty string.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>obj: <code class="type">*</code><dd>The object to convert.</dl><tr><th>Returns<tr><td><dl>A string representation of the <code >obj</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l447">code »</a><span class="member"><a name="goog.string.newLineToBr">goog.string.newLineToBr</a> <span class="args">( str, opt_xml )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Converts \n to <br>s or <br />s.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string in which to convert newlines.<dt>opt_xml: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>Whether to use XML compatible tags.</dl><tr><th>Returns<tr><td><dl>A copy of <code >str</code> with converted newlines.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l262">code »</a><span class="member"><a name="goog.string.normalizeSpaces">goog.string.normalizeSpaces</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Normalizes spaces in a string, replacing all consecutive spaces and tabs
with a single space. Replaces non-breaking space with a space.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string in which to normalize spaces.</dl><tr><th>Returns<tr><td><dl>A copy of <code >str</code> with all consecutive spaces and tabs
replaced with a single space.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l250">code »</a><span class="member"><a name="goog.string.normalizeWhitespace">goog.string.normalizeWhitespace</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Normalizes whitespace in a string, replacing all whitespace chars with
a space.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string in which to normalize whitespace.</dl><tr><th>Returns<tr><td><dl>A copy of <code >str</code> with all whitespace normalized.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l368">code »</a><span class="member"><a name="goog.string.numerateCompare">goog.string.numerateCompare</a> <span class="args">( str1, str2 )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>String comparison function that handles numbers in a way humans might expect.
Using this function, the string "File 2.jpg" sorts before "File 10.jpg". The
comparison is mostly case-insensitive, though strings that are identical
except for case are sorted with the upper-case strings before lower-case.
This comparison function is significantly slower (about 500x) than either
the default or the case-insensitive compare. It should not be used in
time-critical code, but should be fast enough to sort several hundred short
strings (like filenames) with a reasonable delay.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str1: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to compare in a numerically sensitive way.<dt>str2: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to compare <code >str1</code> to.</dl><tr><th>Returns<tr><td><dl>less than 0 if str1 < str2, 0 if str1 == str2, greater than
0 if str1 > str2.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1005">code »</a><span class="member"><a name="goog.string.padNumber">goog.string.padNumber</a> <span class="args">( num, length, opt_precision )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Pads number to given length and optionally rounds it to a given precision.
For example:
<pre>padNumber(1.25, 2, 3) -> '01.250'
padNumber(1.25, 2) -> '01.25'
padNumber(1.25, 2, 1) -> '01.3'
padNumber(1.25, 0) -> '1.25'</pre></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>num: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The number to pad.<dt>length: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The desired length.<dt>opt_precision: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>The desired precision.</dl><tr><th>Returns<tr><td><dl><code >num</code> as a string with the given options.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1325">code »</a><span class="member"><a name="goog.string.parseInt">goog.string.parseInt</a> <span class="args">( value )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Parse a string in decimal or hexidecimal ('0xFFFF') form.
To parse a particular radix, please use parseInt(string, radix) directly. See
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt
This is a wrapper for the built-in parseInt function that will only parse
numbers as base 10 or base 16. Some JS implementations assume strings
starting with "0" are intended to be octal. ES3 allowed but discouraged
this behavior. ES5 forbids it. This function emulates the ES5 behavior.
For more information, see Mozilla JS Reference: http://goo.gl/8RiFj</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>value: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Null">null</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Undefined">undefined</a>)</code><dd>The value to be parsed.</dl><tr><th>Returns<tr><td><dl>The number, parsed. If the string failed to parse, this
will be NaN.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l810">code »</a><span class="member"><a name="goog.string.quote">goog.string.quote</a> <span class="args">( s )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Encloses a string in double quotes and escapes characters so that the
string is a valid JS string.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to quote.</dl><tr><th>Returns<tr><td><dl>A copy of <code >s</code> surrounded by double quotes.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l974">code »</a><span class="member"><a name="goog.string.regExpEscape">goog.string.regExpEscape</a> <span class="args">( s )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Escapes characters in the string that are not safe to use in a RegExp.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type">*</code><dd>The string to escape. If not a string, it will be casted
to one.</dl><tr><th>Returns<tr><td><dl>A RegExp safe, escaped copy of <code >s</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l949">code »</a><span class="member"><a name="goog.string.remove">goog.string.remove</a> <span class="args">( s, ss )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Removes the first occurrence of a substring from a string.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The base string from which to remove.<dt>ss: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to remove.</dl><tr><th>Returns<tr><td><dl>A copy of <code >s</code> with <code >ss</code> removed or the full
string if nothing is removed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l962">code »</a><span class="member"><a name="goog.string.removeAll">goog.string.removeAll</a> <span class="args">( s, ss )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Removes all occurrences of a substring from a string.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The base string from which to remove.<dt>ss: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to remove.</dl><tr><th>Returns<tr><td><dl>A copy of <code >s</code> with <code >ss</code> removed or the full
string if nothing is removed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l931">code »</a><span class="member"><a name="goog.string.removeAt">goog.string.removeAt</a> <span class="args">( s, index, stringLength )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Removes a substring of a specified length at a specific
index in a string.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>s: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The base string from which to remove.<dt>index: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The index at which to remove the substring.<dt>stringLength: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The length of the substring to remove.</dl><tr><th>Returns<tr><td><dl>A copy of <code >s</code> with the substring removed or the full
string if nothing is removed or the input is invalid.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l987">code »</a><span class="member"><a name="goog.string.repeat">goog.string.repeat</a> <span class="args">( string, length )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Repeats a string n times.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>string: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to repeat.<dt>length: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The number of times to repeat.</dl><tr><th>Returns<tr><td><dl>A string containing <code >length</code> repetitions of
<code >string</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l1360">code »</a><span class="member"><a name="goog.string.splitLimit">goog.string.splitLimit</a> <span class="args">( str, separator, limit )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Splits a string on a separator a limited number of times.
This implementation is more similar to Python or Java, where the limit
parameter specifies the maximum number of splits rather than truncating
the number of results.
See http://docs.python.org/2/library/stdtypes.html#str.split
See JavaDoc: http://goo.gl/F2AsY
See Mozilla reference: http://goo.gl/dZdZs</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>String to split.<dt>separator: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The separator.<dt>limit: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The limit to the number of splits. The resulting array
will have a maximum length of limit+1. Negative numbers are the same
as zero.</dl><tr><th>Returns<tr><td><dl>The string, split.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l42">code »</a><span class="member"><a name="goog.string.startsWith">goog.string.startsWith</a> <span class="args">( str, prefix )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Fast prefix-checker.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The string to check.<dt>prefix: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A string to look for at the start of <code >str</code>.</dl><tr><th>Returns<tr><td><dl>True if <code >str</code> begins with <code >prefix</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/string/string.js.src.html#l229">code »</a><span class="member"><a name="goog.string.stripNewlines">goog.string.stripNewlines</a> <span class="args">( str )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Takes a string and replaces newlines with a space. Multiple lines are
replaced with a single space.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>str: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/St