Function Namespace Pot.Text
Defined in: <pot.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Pot.Text(x, (ignoreBoolean))
Text.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
Pot.Text.br(string, (useXML), (all))
Converts the new lines (\n) to
s or s. |
| <static> |
Pot.Text.camelize(s)
Convert a string to "Camelcase".
|
| <static> |
Pot.Text.canonicalizeNL(s)
Replaces new lines with unix style (\n).
|
| <static> |
Pot.Text.chr()
Shortcut of String.fromCharCode().
|
| <static> |
Pot.Text.dec(value)
Decrement the argument value.
|
| <static> |
Pot.Text.endsWith(string, suffix, (ignoreCase))
Check whether a string ends with suffix.
|
| <static> |
Pot.Text.extract(string, pattern, (index))
Extract a substring from string .
|
| <static> |
Pot.Text.hyphenize(s)
Convert a string to "hyphen-delimited syntax".
|
| <static> |
Pot.Text.inc(value)
Increment the argument value.
|
| <static> |
Pot.Text.indent(string, (size), (ch))
Indent a string.
|
| <static> |
Pot.Text.lower(s)
A shortcut function of .toLowerCase().
|
| <static> |
Pot.Text.ltrim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000) from left side.
|
| <static> |
Pot.Text.normalizeSpace(s, (spacer))
Normalize whitespaces.
|
| <static> |
Pot.Text.ord(s)
A shortcut of charCodeAt(0).
|
| <static> |
Pot.Text.rtrim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000) from right side.
|
| <static> |
Pot.Text.splitBySpace(s)
Split a string into an array by whitespace.
|
| <static> |
Pot.Text.startsWith(string, prefix, (ignoreCase))
Check whether a string starts with prefix.
|
| <static> |
Pot.Text.stringify(x, (ignoreBoolean))
Evaluate a string can be a scalar value only.
|
| <static> |
Pot.Text.strip(s, (chars), (ignoreCase))
Remove all whitespaces in a string.
|
| <static> |
Pot.Text.stripTags(text)
Remove the HTML/XML tags from string.
|
| <static> |
Pot.Text.toCharCode(string, (callback))
Convert to character code array from a string.
|
| <static> |
Pot.Text.toHankakuCase(text)
全角英数記号文字を半角英数記号文字に変換
Convert the ascii symbols and alphanumeric characters to
the zenkaku symbols and alphanumeric characters.
|
| <static> |
Pot.Text.toHankanaCase(text)
全角カタカナを半角カタカナに変換
Convert the zenkaku katakana to the hankaku katakana.
|
| <static> |
Pot.Text.toHanSpaceCase(text)
全角スペースを半角スペースに変換
Convert the em space(U+3000) to the single space(U+0020).
|
| <static> |
Pot.Text.toHiraganaCase(text)
全角カタカナを全角ひらがなに変換
Convert the zenkaku katakana to the zenkaku hiragana.
|
| <static> |
Pot.Text.toKatakanaCase(text)
全角ひらがなを全角カタカナに変換
Convert the zenkaku hiragana to the zenkaku katakana.
|
| <static> |
Pot.Text.toZenkakuCase(text)
半角英数記号文字を全角英数記号文字に変換
Convert the zenkaku symbols and alphanumeric characters to
the ascii symbols and alphanumeric characters.
|
| <static> |
Pot.Text.toZenkanaCase(text)
半角カタカナを全角カタカナに変換 (濁音含む)
Convert the hankaku katakana to
the zenkaku katakana (including dullness).
|
| <static> |
Pot.Text.toZenSpaceCase(text)
半角スペースを全角スペースに変換
Convert the single space(U+0020) to the em space(U+3000).
|
| <static> |
Pot.Text.trim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000).
|
| <static> |
Pot.Text.truncate(string, (maxLen), (ellipsis))
Truncates a string to a certain length and
adds ellipsis (e.g.
|
| <static> |
Pot.Text.truncateMiddle(string, (maxLen), (ellipsis))
Truncate a string in the middle,
adds ellipsis(e.g.
|
| <static> |
Pot.Text.underscore(s)
Convert a string to "Underscore-syntax".
|
| <static> |
Pot.Text.unindent(string, (size), (ch))
Unindent a string.
|
| <static> |
Pot.Text.unwrap(string, unwrapper, rightWrap)
Unwraps a string by specific character.
|
| <static> |
Pot.Text.upper(s)
A shortcut function of .toUpperCase().
|
| <static> |
Pot.Text.wrap(string, wrapper, right)
Wraps a string by specific character.
|
Function Namespace Detail
Pot.Text(x, (ignoreBoolean))
Text.
String utilities.
Evaluate a string can be a scalar value only.
Return "1" when argument was passed as Boolean's `true`.
This function can treat XML object that
will be string by toString method.
- Parameters:
- {*} x
- Any value.
- {Boolean} (ignoreBoolean)
- Optional, Ignores Boolean value.
- Returns:
- {String} Value as a string.
- See:
- Pot.Text.stringify
Method Detail
<static>
{Function}
Pot.Text.br(string, (useXML), (all))
Converts the new lines (\n) to
s or
s.
s or
s.
var string = '1. foo.\n2. bar.\n3. baz.'; var result = br(string); debug(result); // @results '1. foo.<br>\n2. bar.<br>\n3. baz.'
var string = ' - foo.\n - bar.\n - baz.'; var result = br(string, true); debug(result); // @results ' - foo.<br />\n - bar.<br />\n - baz.'
var string = '<ul><li>foo<br />fooo</li><li>bar\nbaaar</li></ul>'; var result = br(string); debug(result); // @results '<ul><li>foo<br />fooo</li><li>bar<br />\nbaaar</li></ul>'
var string = [
'<div>',
'<h1>Hoge</h1>',
'<p>',
'foo',
'bar',
'</p>',
'<span>baz</span>',
'<b>qux</b>',
'<pre>',
'function hoge() {',
' return this;',
'}',
'</pre>',
'<hr>',
'</div>'
].join('\n');
var result = br(string);
debug(result);
// @results
// <div>
// <h1>Hoge</h1>
// <p>
// foo<br>
// bar<br>
// </p>
// <span>baz</span><br>
// <b>qux</b><br>
// <pre>
// function hoge() {
// return this;
// }
// </pre>
// <hr>
// </div>
var string = [
'<div>',
'<div>foo</div>',
'<div>bar</div>',
'<div>baz</div>',
'</div>'
].join('\n');
var result = br(string, false, true);
debug(result);
// @results
// <div><br>
// <div>foo</div><br>
// <div>bar</div><br>
// <div>baz</div><br>
// </div>
- Parameters:
- {String} string
- The string in which to convert newlines.
- {Boolean} (useXML)
- Whether to use XML compatible tags.
- {Boolean} (all)
- Whether convert all of the new lines.
- Returns:
- {String} A copy string of `string` with converted newlines.
<static>
{Function}
Pot.Text.camelize(s)
Convert a string to "Camelcase".
var result = camelize('font-size');
debug(result);
// @results 'fontSize'
- Parameters:
- {String} s
- A target string.
- Returns:
- {String} A converted string.
<static>
{Function}
Pot.Text.canonicalizeNL(s)
Replaces new lines with unix style (\n).
var string = 'foo\r\nbar\rbaz\n'; var result = canonicalizeNL(string); debug(result); // @results 'foo\nbar\nbaz\n'
- Parameters:
- {String} s
- The input string.
- Returns:
- {String} The result string.
<static>
{Function}
Pot.Text.chr()
Shortcut of String.fromCharCode().
This function fixed an error on 'stack overflow' (or RangeError).
e.g. String.fromCharCode.apply(null, new Array(100000000));
debug(chr(97));
// @results 'a'
debug(chr(97, 98, 99));
// @results 'abc'
debug(chr(
[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
));
// @results 'Hello World!'
- Parameters:
- {...Number|Array} (...)
- Unicode numbers, or an array.
- Returns:
- {String} Converted string from Unicode number.
<static>
{Function}
Pot.Text.dec(value)
Decrement the argument value.
This decrementation like Perl and PHP etc that
uses alphabets [a-z] + [A-Z] and digits [0-9] as
magic-decrement,
(i.e., different with c-style decrement.).
Note Magic-Decrement cannot works with perfectly,
so that Perl and Ruby etc did not implemented magic-decerement.
debug(dec('100'));
// @results '99'
debug(dec('a1'));
// @results 'a0'
debug(dec('Ba'));
// @results 'Az'
debug(dec('aaa'));
// @results 'zz'
var s = 'AC';
for (var i = 0; i < 10; i++) {
s = dec(s);
debug(s);
}
// @results
// AB
// AA
// Z
// Y
// X
// W
// V
// U
// T
// S
- Parameters:
- {String|Number|Date|*} value
- The value to decrement.
- Returns:
- {String|Number|Date|*} The decremented value.
- See:
- Pot.Text.inc
<static>
{Function}
Pot.Text.endsWith(string, suffix, (ignoreCase))
Check whether a string ends with suffix.
var result = endsWith('foo bar baz', 'baz');
debug(result);
// @results true
var result = endsWith('foo bar baz foo bar', 'foo');
debug(result);
// @results false
var result = endsWith('bar foo foo bar baz FOo', 'foo', true);
debug(result);
// @results true
- Parameters:
- {String} string
- The string to check.
- {String} suffix
- The subject suffix.
- {Boolean} (ignoreCase)
- Whether ignore case.
- Returns:
- {Boolean} True if `string` ends with `suffix`.
<static>
{Function}
Pot.Text.extract(string, pattern, (index))
Extract a substring from string .
var result = extract('foo:bar', /:(\w+)$/);
debug(result);
// @results 'bar'
var result = extract('foo:bar', /^:(\w+)/);
debug(result);
// @results ''
var result = extract('foo.html', /(foo|bar)\.([^.]+)$/, 2);
debug(result);
// @results 'html'
var result = extract('foobar', 'foo');
debug(result);
// @results 'foo'
var result = extract('foobar', 'fo+');
debug(result);
// @results ''
- Parameters:
- {String|*} string
- A target string.
- {RegExp|String} pattern
- A pattern for extract substring.
- {Number} (index)
- (Optional) Index number of captured group.
- Returns:
- {String} Return extracted substring.
<static>
{Function}
Pot.Text.hyphenize(s)
Convert a string to "hyphen-delimited syntax".
var result = hyphenize('fontSize');
debug(result);
// @results 'font-size'
- Parameters:
- {String} s
- A target string.
- Returns:
- {String} A converted string.
<static>
{Function}
Pot.Text.inc(value)
Increment the argument value.
This incrementation like Perl and PHP etc that
uses alphabets [a-z] + [A-Z] and digits [0-9]
as magic-increment,
(i.e., different with c-style increment.).
debug(inc('99'));
// @results '100'
debug(inc('a0'));
// @results 'a1'
debug(inc('Az'));
// @results 'Ba'
debug(inc('zz'));
// @results 'aaa'
var s = 'X';
for (var i = 0; i < 10; i++) {
s = inc(s);
debug(s);
}
// @results
// Y
// Z
// AA
// AB
// AC
// AD
// AE
// AF
// AG
// AH
- Parameters:
- {String|Number|Date|*} value
- The value to increment.
- Returns:
- {String|Number|Date|*} The incremented value.
- See:
- Pot.Text.dec
<static>
{Function}
Pot.Text.indent(string, (size), (ch))
Indent a string.
var s = 'foo bar baz'; debug(indent(s)); // ' foo bar baz' debug(indent(s, 4)); // ' foo bar baz' debug(indent(s, 1, '\t')); // '\tfoo bar baz'
var s = 'foo\nbar\nbaz'; debug(indent(s, 1, '\t')); // '\tfoo\n\tbar\n\tbaz'
- Parameters:
- {String} string
- A target string.
- {Number} (size)
- (Optional) A length of indent (default=2).
- {String} (ch)
- (Optional) A character to indent (default=' ').
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.lower(s)
A shortcut function of .toLowerCase().
Convert a string to lowercase.
debug(lower('Hello World!'));
// @results 'hello world!'
- Parameters:
- {String} s
- A target string.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.ltrim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000) from left side.
White spaces will not removed when specified the second argument.
debug( ltrim(' hoge ') );
// @results 'hoge '
//
// White spaces will not removed when
// specified the second argument.
//
debug( ltrim('a cba', 'ac') );
// @results ' cba'
- Parameters:
- {String} s
- A target string.
- {String} (chars)
- (Optional) Removing characters.
- {Boolean} (ignoreCase)
- (Optional) Whether ignore case on RegExp.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.normalizeSpace(s, (spacer))
Normalize whitespaces.
One or more whitespaces will be converted into one space.
If passed any character to the second argument then
convertion will use it.
var s = 'Hello \r\n World \r\n \t !'; debug(normalizeSpace(s)); // @results 'Hello World !'
var s = 'foo bar baz'; debug(normalizeSpace(s, '+')); // @results 'foo+bar+baz'
- Parameters:
- {String} s
- The target string.
- {String} (spacer)
- (Optional) Convertion character.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.ord(s)
A shortcut of charCodeAt(0).
debug(ord('Hello'));
// @results 72
- Parameters:
- {String} s
- Target string.
- Returns:
- {Number} The first index Unicode number in `s`.
<static>
{Function}
Pot.Text.rtrim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000) from right side.
White spaces will not removed when specified the second argument.
debug( rtrim(' hoge ') );
// @results ' hoge'
//
// White spaces will not removed when
// specified the second argument.
//
debug( rtrim('abc a', 'ac') );
// @results 'abc '
- Parameters:
- {String} s
- A target string.
- {String} (chars)
- (Optional) Removing characters.
- {Boolean} (ignoreCase)
- (Optional) Whether ignore case on RegExp.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.splitBySpace(s)
Split a string into an array by whitespace.
All empty items will be removed for the result array.
var s = ' Hello \r\n World \r\n \t ! '; debug(splitBySpace(s)); // @results ['Hello', 'World', '!']
- Parameters:
- {String} s
- The target string.
- Returns:
- {Array} The result array.
<static>
{Function}
Pot.Text.startsWith(string, prefix, (ignoreCase))
Check whether a string starts with prefix.
var result = startsWith('foo bar baz', 'foo');
debug(result);
// @results true
var result = startsWith('bar foo foo bar baz foo', 'foo');
debug(result);
// @results false
var result = startsWith('FoO bar foo foo bar baz foo', 'foo', true);
debug(result);
// @results true
- Parameters:
- {String} string
- The string to check.
- {String} prefix
- The subject prefix.
- {Boolean} (ignoreCase)
- Whether ignore case.
- Returns:
- {Boolean} True if `string` begins with `prefix`.
<static>
{Function}
Pot.Text.stringify(x, (ignoreBoolean))
Evaluate a string can be a scalar value only.
Return "1" when argument was passed as true.
This function can treat XML object that
will be string by toString method.
debug(stringify({}));
// @results ''
debug(stringify([]));
// @results ''
debug(stringify(0));
// @results '0'
debug(stringify(-100.02));
// @results '-100.02'
debug(stringify(new Date()));
// @results ''
debug(stringify(null));
// @results ''
debug(stringify(void 0));
// @results ''
debug(stringify(false));
// @results ''
debug(stringify(true));
// @results '1'
debug(stringify(''));
// @results ''
debug(stringify('hoge'));
// @results 'hoge'
debug(stringify(new String('hoge')));
// @results 'hoge'
debug(stringify(new Boolean(false)));
// @results ''
debug(stringify(new Boolean(true)));
// @results '1'
debug(stringify([100]));
// @results ''
- Parameters:
- {*} x
- Any value.
- {Boolean} (ignoreBoolean)
- Optional, Ignores Boolean value.
- Returns:
- {String} Value as a string.
<static>
{Function}
Pot.Text.strip(s, (chars), (ignoreCase))
Remove all whitespaces in a string.
var s = ' Hello World ! \r\n.'; debug(strip(s)); // @results 'HelloWorld!.'
var s = 'foo looooooooool'; debug(strip(s, 'o')); // @results 'f ll'
- Parameters:
- {String} s
- The target string.
- {String} (chars)
- (Optional) Removing characters.
- {Boolean} (ignoreCase)
- (Optional) Whether ignore case on RegExp.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.stripTags(text)
Remove the HTML/XML tags from string.
var html = '<div>Hoge</div>foo<br>bar<i>baz</i>'; var result = stripTags(html); debug(result); // @results 'Hoge foo bar baz'
- Parameters:
- {String} text
- The target string.
- Returns:
- {String} A result string that removed all of tags.
<static>
{Function}
Pot.Text.toCharCode(string, (callback))
Convert to character code array from a string.
var string = 'foo bar ほげ'; var result = Pot.toCharCode(string); Pot.debug(result); // [102, 111, 111, 32, 98, 97, 114, 32, 12411, 12370]
var string = 'abc';
var result = Pot.toCharCode(string, function(code) {
return code.toString(16);
});
Pot.debug(result);
// ['61', '62', '63']
- Parameters:
- {String} string
- A target string.
- {Function} (callback)
- (Optional) A callback function for code.
- Returns:
- {Array} A result array.
<static>
{Function}
Pot.Text.toHankakuCase(text)
全角英数記号文字を半角英数記号文字に変換
Convert the ascii symbols and alphanumeric characters to
the zenkaku symbols and alphanumeric characters.
Based:
Hiragana/Katakana Library
http://code.google.com/p/kanaxs/
debug(toHankakuCase('Hello World! 12345'));
// @results 'Hello World! 12345'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The conveted string.
<static>
{Function}
Pot.Text.toHankanaCase(text)
全角カタカナを半角カタカナに変換
Convert the zenkaku katakana to the hankaku katakana.
debug(toHankanaCase('ボポヴァアィイゥウェエォオ'));
// @results 'ボポヴァアィイゥウェエォオ'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string to hankaku katakana.
<static>
{Function}
Pot.Text.toHanSpaceCase(text)
全角スペースを半角スペースに変換
Convert the em space(U+3000) to the single space(U+0020).
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string.
<static>
{Function}
Pot.Text.toHiraganaCase(text)
全角カタカナを全角ひらがなに変換
Convert the zenkaku katakana to the zenkaku hiragana.
debug(toHiraganaCase('ボポヴァアィイゥウェエォオ'));
// @results 'ぼぽう゛ぁあぃいぅうぇえぉお'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string to hiragana.
<static>
{Function}
Pot.Text.toKatakanaCase(text)
全角ひらがなを全角カタカナに変換
Convert the zenkaku hiragana to the zenkaku katakana.
debug(toKatakanaCase('ぼぽう゛ぁあぃいぅうぇえぉお'));
// @results 'ボポヴァアィイゥウェエォオ'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string to katakana.
<static>
{Function}
Pot.Text.toZenkakuCase(text)
半角英数記号文字を全角英数記号文字に変換
Convert the zenkaku symbols and alphanumeric characters to
the ascii symbols and alphanumeric characters.
debug(toZenkakuCase('Hello World! 12345'));
// @results 'Hello World! 12345'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string.
<static>
{Function}
Pot.Text.toZenkanaCase(text)
半角カタカナを全角カタカナに変換 (濁音含む)
Convert the hankaku katakana to
the zenkaku katakana (including dullness).
debug(toZenkanaCase('ボポヴァアィイゥウェエォオ'));
// @results 'ボポヴァアィイゥウェエォオ'
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string to zenkaku katakana.
<static>
{Function}
Pot.Text.toZenSpaceCase(text)
半角スペースを全角スペースに変換
Convert the single space(U+0020) to the em space(U+3000).
- Parameters:
- {String} text
- The input string.
- Returns:
- {String} The converted string.
<static>
{Function}
Pot.Text.trim(s, (chars), (ignoreCase))
Trim the white spaces including em (U+3000).
White spaces will not removed when specified the second argument.
debug( trim(' hoge ') );
// @results 'hoge'
//
// White spaces will not removed when
// specified the second argument.
//
debug( trim('abbbcc cc ', 'ab') );
// @results 'cc cc '
- Parameters:
- {String} s
- A target string.
- {String} (chars)
- (Optional) Removing characters.
- {Boolean} (ignoreCase)
- (Optional) Whether ignore case on RegExp.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.truncate(string, (maxLen), (ellipsis))
Truncates a string to a certain length and
adds ellipsis (e.g., '...') if necessary.
var string = 'Helloooooooooo Wooooooooorld!! Hellooooo Woooooorld!!'; debug(string + ' (length = ' + string.length + ')'); var result = truncate(string, 10); debug(result + ' (length = ' + result.length + ')'); // @results result = 'Hellooo...' (length = 10)
var string = 'foooooooo baaaaaaaaar baaaaaaaaaaz'; debug(string + ' (length = ' + string.length + ')'); var result = truncate(string, 16, '...more'); debug(result + ' (length = ' + result.length + ')'); // @results result = 'foooooooo...more' (length = 16)
- Parameters:
- {String} string
- A target string.
- {Number} (maxLen)
- The maximum number of characters to truncates.
- {String} (ellipsis)
- Optional ellipsis string.
- Returns:
- {String} The truncated string.
<static>
{Function}
Pot.Text.truncateMiddle(string, (maxLen), (ellipsis))
Truncate a string in the middle,
adds ellipsis(e.g., '...') if necessary.
var string = 'Helloooooooooo Wooooooooorld!! Hellooooo Woooooorld!!'; debug(string + ' (length = ' + string.length + ')'); var result = truncateMiddle(string, 15); debug(result + ' (length = ' + result.length + ')'); // @results result = 'Helloo...orld!!' (length = 15)
var string = 'foooooooo baaaaaaaaar baaaaaaaaaaz'; debug(string + ' (length = ' + string.length + ')'); var result = truncateMiddle(string, 18, '(...)'); debug(result + ' (length = ' + result.length + ')'); // @results result = 'foooooo(...)aaaaaz' (length = 18)
- Parameters:
- {String} string
- A target string.
- {Number} (maxLen)
- The maximum number of characters to truncates.
- {String} (ellipsis)
- Optional ellipsis string.
- Returns:
- {String} The truncated string.
<static>
{Function}
Pot.Text.underscore(s)
Convert a string to "Underscore-syntax".
var result = underscore('rawInput');
debug(result);
// @results 'raw_input'
- Parameters:
- {String} s
- A target string.
- Returns:
- {String} A converted string.
<static>
{Function}
Pot.Text.unindent(string, (size), (ch))
Unindent a string.
var s = ' foo bar baz'; debug(unindent(s)); // 'foo bar baz' debug(unindent(s, 4)); // ' foo bar baz' debug(unindent(s, 1, '\t')); // ' foo bar baz'
var s = '\tfoo\n\tbar\n\tbaz'; debug(unindent(s, 1, '\t')); // 'foo\nbar\nbaz'
- Parameters:
- {String} string
- A target string.
- {Number} (size)
- (Optional) A length of indent (default=2).
- {String} (ch)
- (Optional) A character to indent (default=' ').
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.unwrap(string, unwrapper, rightWrap)
Unwraps a string by specific character.
Unwrapper string can specify an array.
That must has 2 or more items.
var s = '"hoge"'; debug(unwrap(s, '"')); // @results 'hoge'
var s = '(hoge)';
debug(unwrap(s, ['(', ')']));
// @results 'hoge'
var s = '(L(hoge)R)';
debug(unwrap(unwrap(s, '()'), ['L(', ')R']));
// @results 'hoge'
- Parameters:
- {String} string
- The target string.
- {String|Array} unwrapper
- The unwrapper character.
- {String} rightWrap
- (optional) The right unwrapper.
- Returns:
- {String} The result string.
<static>
{Function}
Pot.Text.upper(s)
A shortcut function of .toUpperCase().
Convert a string to uppercase.
debug(upper('Hello World!'));
// @results 'HELLO WORLD!'
- Parameters:
- {String} s
- A target string.
- Returns:
- {String} A result string.
<static>
{Function}
Pot.Text.wrap(string, wrapper, right)
Wraps a string by specific character.
Wrapper string can specify an array.
That must has 2 or more items.
var s = 'hoge'; debug(wrap(s, '"')); // @results '"hoge"'
var s = 'hoge';
debug(wrap(s, ['(', ')']));
// @results '(hoge)'
var s = 'hoge'; debug(wrap(s, '()') + wrap(s, '[]')); // @results '(hoge)[hoge]'
- Parameters:
- {String} string
- The target string.
- {String|Array} wrapper
- The wrapper character.
- {String} right
- (optional) The right wrapper.
- Returns:
- {String} The result string.