Additional functions on the JS String object
| String | Additional functions on the JS String object |
| Properties | |
| htmlEscapeChars | Static Array of characters to be translated by escapeHtml and unEscapeHtml |
| Functions | |
| after | returns all the characters after the first count characters |
| before | returns all the characters before the last count characters |
| charToHtmlEntity | returns the HTML/XML entity of the supplied character in &#code; format where code is the decimal ASCII code |
| compareAlpha | Static A static sort function that will compare two strings by lexigraphical order. |
| compareAlphaNoCase | Static A case-insensitive version of String.compareAlpha |
| compareAlphaReverse | Static A descending version of compareAlpha. |
| compareAlphaReverseNoCase | Static A case-insensitive version of String.compareAlphaReverse |
| compareNatural | Static A static sort function that will compare two strings in a natural way. |
| compareNaturalNoCase | Static A case-insensitive version of String.compareNatural |
| compareNaturalReverse | Static A descending version of compareNatural. |
| compareNaturalReverseNoCase | Static A case-insensitive version of String.compareNaturalReverse |
| compareNumeric | Static A static sort function that will compare two strings by lexigraphical order. |
| compareNumericReverse | Static A descending version of compareNumeric. |
| endsWith | returns true if this string ends with supplied string |
| escapeHtml | replaces common symbols with their HTML entity equivalents |
| escapeRegex | returns string with symbols that might be interpreted as regex escaped |
| escapeJs | returns string with symbols that might be interpreted as JavaScript escaped |
| format | returns a string with parameters replaced |
| getLineIterator | returns java Iterator that produces a line at a time for this string |
| htmlEntityToChar | Static returns the chatacter representation of the supplied HTML/XML entity |
| left | returns the left side of a string |
| listAppend | returns new list (string) with value appended (does not modify original string). |
| listAppendUnique | returns new list (string) with value appended, if not already in list |
| listAppendUniqueNoCase | returns new list (string) with value appended, if not already in list, ignoring case |
| listAfter | returns this list minus the first element. |
| listBefore | returns this list minus the last element. |
| listContains | returns true if list contains the value. |
| listContainsNoCase | returns true if list contains the value, ignoring case. |
| listFind | returns the index of a value in a list |
| listFindNoCase | returns the index of a value in a list, ignoring case |
| listFirst | returns the first value of a list. |
| listLast | returns the last value of a list. |
| listAt | returns the list value at a specific location, or “”. |
| listLen | returns the length of a list |
| listGetUnique | returns new list (string) with each item represented only once |
| listMakeUniqueNoCase | returns new list (string) with each item represented only once, regardless of case. |
| listQualify | returns new list (string) with each item surrounded by a qualifying symbol |
| listSame | returns true if the provided list contains the smae elements as this list regardless of order. |
| listSameNoCase | returns true if the provided list contains the smae elements as this list regardless of order. |
| listSort | returns a copy of this list sorted by the supplied sort function |
| listToArray | returns an array of the items in this list |
| toFixedWidth | returns this string padded/truncated to the specified length |
| parseJson | Converts a JSON (http://www.json.org) string into an object |
| right | returns the right side of a string |
| repeat | returns a copy of this string repeated count times |
| splitCap | returns an array of the “words” in this string as delimited by Capital letters |
| startsWith | returns true if this string starts with supplied string |
| titleCap | Capitalizes the first letter of every word in string |
| trim | returns a new string with beginning and trailing whitespace removed |
| trimIndent | returns a new string with the initial white space on each line trimmed |
| unEscapeHtml | reverses the replacements in escapeHtml |
| hashCode | returns java.lang.String.hasCode() for this string |
| hashEquals | Returns true if the plaintext password matches the encrypted password |
| toHash | Returns a copy of this string encrypted with a strong one-way hash in base64 format. |
| decrypt | Returns the unencrypted string contained in this string |
| encrypt | Encrypts this string using a password. |
| toJava | returns a new java.lang.String of this string |
| toXml | returns an E4X XML object from this string, or throws an exception if not possible |
| toXmlDoc | returns an org.w3c.dom.Document object from this string, or throws an exception if not possible |
| escapeUrl | returns a URL encoded version of this string |
Static Array of characters to be translated by escapeHtml and unEscapeHtml
String.prototype.after=function( count, caseSensitive )
returns all the characters after the first count characters
| count | number of characters to skip, a string or a RegExp object |
| caseSensitive | Optional, default false if count is a string, should the match be case sensitive? |
string that appears after count, or null if not possible
var string = "JoeBlow"
Myna.println(string.after(3));//prints Blow
Myna.println(string.after(/e/,true));//prints Blow
Myna.println(string.after(/^joe/i,true));//prints Blow
Myna.println(string.after("joe"));//prints Blow
Myna.println(string.after("joe",true));//prints null because we forced case sensitivity
var requestDir = $server.requestDir;
// this is an example only. $server.requestUrl does this for you
var requestUrl = requestDir.after($server.rootDir);
String.prototype.before=function( count )
returns all the characters before the last count characters
| count | number of characters to remove from the end of this string, a string, or a RegExp object |
| caseSensitive | Optional, default false if count is a string, should the match be case sensitive? |
string that appears before count, or null if not possible
var string = "JoeBlow"
Myna.println(string.before(4));//prints Joe
Myna.println(string.before(/o/,true));//prints J
Myna.println(string.before(/o$/,true));//prints JoeBl
Myna.println(string.before(/blow/i,true));//prints Joe
Myna.println(string.before("blow"));//prints Joe
Myna.println(string.before("blow",true));//prints null because we forced case sensitivity
var requestUrl = $server.requestUrl;
var contextRelativeUrl = requestUrl.after($server.rootUrl);
// this is an example only. $server.rootDir does this for you
var rootDir = $server.requestDir.before(contextRelativeUrl);
String.charToHtmlEntity = function( c )
returns the HTML/XML entity of the supplied character in &#code; format where code is the decimal ASCII code
| c | 1 character string to convert |
String.compareAlpha = function( a, b )
Static A static sort function that will compare two strings by lexigraphical order.
| a | first string to compare |
| b | second string to compare |
| -1 | if a > b |
| 0 | if a == b |
| 1 | if a < b |
String.compareAlphaNoCase = function( a, b )
Static A case-insensitive version of String.compareAlpha
String.compareAlphaReverse = function( a, b )
Static A descending version of compareAlpha.
| a | first string to compare |
| b | second string to compare |
| -1 | if a < b |
| 0 | if a == b |
| 1 | if a > b |
see compareAlpha
String.compareAlphaReverseNoCase = function( a, b )
Static A case-insensitive version of String.compareAlphaReverse
String.compareNatural = function( a, b )
Static A static sort function that will compare two strings in a natural way.
| a | first string to compare |
| b | second string to compare |
| -1 | if a > b |
| 0 | if a == b |
| 1 | if a < b |
The standard sort function does ASCII comparisons of the entire string. Humans tend to sort based on parts of the string, applying numeric and alpha sorts as appropriate, and ignoring case. Take this list:
var stringArray="A8,a10,A11,a14c,a14b9,a14B10,A14B10,a14b10,a9".split(/,/);
Calling stringArray.sort() will result in
A11
A14B10
A8
a10
a14B10
a14b10
a14b9
a14c
a9
This is a valid ASCII sort, but doesn’t look “right” to humans. Calling stringArray.sort(String.compareNatural) will result in
A8
a9
a10
A11
a14b9
A14B10
a14B10
a14b10
a14c
String.compareNaturalNoCase = function( a, b )
Static A case-insensitive version of String.compareNatural
String.compareNaturalReverse = function( a, b )
Static A descending version of compareNatural.
| a | first string to compare |
| b | second string to compare |
| -1 | if a < b |
| 0 | if a == b |
| 1 | if a > b |
see compareNatural
String.compareNaturalReverseNoCase = function( a, b )
Static A case-insensitive version of String.compareNaturalReverse
String.compareNumeric = function( a, b )
Static A static sort function that will compare two strings by lexigraphical order.
| a | first string to compare |
| b | second string to compare |
| -1 | if a > b |
| 0 | if a == b |
| 1 | if a < b |
String.compareNumericReverse = function( a, b )
Static A descending version of compareNumeric.
| a | first string to compare |
| b | second string to compare |
| -1 | if a < b |
| 0 | if a == b |
| 1 | if a > b |
see compareNumeric
String.prototype.endsWith = function( str, caseSensitive )
returns true if this string ends with supplied string
| str | string to match |
| caseSensitive | Optional, default false Should the match be case sensitive? |
Myna.println(“BobDobb”.endsWith(“dobb”))//prints true Myna.println(“BobDobb”.endsWith(“dobb”,true))//prints false
String.prototype.escapeHtml=function( string )
replaces common symbols with their HTML entity equivalents
the purpose of this function is to prevent a string from being interpreted as HTML/JavaScript when output on a webpage.
converted string
escapes the following symbols:
; becomes ;
& becomes &
# becomes #
< becomes <
> becomes >
' becomes '
" becomes "
( becomes (
) becomes )
% becomes %
+ becomes +
- becomes -
See: $req.data,<$req.rawData>,<unEscapeHtml>
String.prototype.escapeRegex=function( string )
returns string with symbols that might be interpreted as regex escaped
the purpose of this function is to prevent a string from being interpreted as a regex string when using new RegExp
converted string
String.prototype.escapeJs=function()
returns string with symbols that might be interpreted as JavaScript escaped
the purpose of this function is to prevent a string from being interpreted as JavaScript when used as a string literal in a JS expression
converted string
//index.ejs
<script>
var postTitle = "<%=Post.title.escapeJs()%>";
</script>
String.prototype.format=function( values )
returns a string with parameters replaced
| values... | Either multiple value parameters, a single parameter array or a JS object containing key/value pairs |
This provides a very simple templating system for strings. Bracketed terms (e.g.{1} or {paramName}) in this string are replaced with that matching index in values. For parameter list or a single parameter array, positional terms ({0},{1},...{n}) are replaced. For a single object parameter, matching property names are replaced ({age},{height},{DOB})
converted string
var saying = "This is the {0} of our {1}. words:{0},{1}".format("summer","discontent")
var saying2 = "This is the {season} of our {feeling}. words:{season},{feeling}".format({
season:"summer",
feeling:"discontent"
})
String.prototype.getLineIterator = function()
returns java Iterator that produces a line at a time for this string
If you are working with large strings, split().forEach() may be inefficient. This function produces a Java Iterator object that can be used to efficiently loop over all the lines in this string.
//big text chunk
var text = qry.data[0].big_text_field;
for (var line in text.getLineIterator()){
... do stuff with line...
}
String.htmlEntityToChar = function( e )
Static returns the chatacter representation of the supplied HTML/XML entity
| e | HTML/XML entity in &#code; format where code is the decimal ASCII code |
String.prototype.left=function( count )
returns the left side of a string
| count | number of characters to return |
The left count characters of string
String.prototype.listAppend=function( val, delimiter, qualifier )
returns new list (string) with value appended (does not modify original string).
| val | String value to append |
| delimiter | Optional, default “,” String delimiter to append to this string before val. If this string is empty, or currently ends with delimiter, delimiter will not be appended. returned string |
| qualifier | Optional, default null String to put before and after val |
A new list with val appended.
String.prototype.listAppendUnique=function( val, delimiter, qualifier )
returns new list (string) with value appended, if not already in list
| val | String value to append |
| delimiter | Optional, default “,” String delimiter to append to this string before val. If this string is empty, or currently ends with delimiter, delimiter will not be appended. returned string |
| qualifier | Optional, default null String to put before and after val |
A new list with val appended.
String.prototype.listAppendUniqueNoCase=function( val, delimiter, qualifier )
returns new list (string) with value appended, if not already in list, ignoring case
| val | String value to append |
| delimiter | Optional, default “,” String delimiter to append to this string before val. If this string is empty, or currently ends with delimiter, delimiter will not be appended. returned string |
| qualifier | Optional, default null String to put before and after val |
String.prototype.listAfter=function( delimiter, qualifier )
returns this list minus the first element.
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
String.prototype.listBefore=function( delimiter )
returns this list minus the last element.
| delimiter | Optional default ‘,’ String delimiter between values |
String.prototype.listContains=function( val, delimiter, qualifier )
returns true if list contains the value.
| val | String Value to search for. If val is a list with the same delimiter then all values in val must also be in this string |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String found before and after val Returns: true if val exists in this string |
String.prototype.listContainsNoCase=function( val, delimiter, qualifier )
returns true if list contains the value, ignoring case.
| val | String Value to search for. If val is a list with the same delimiter then all values in val must also be in this string |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
true if val exists in list
String.prototype.listFind=function( val, startFrom, delimiter, qualifier )
returns the index of a value in a list
| val | String value to search for |
| startFrom | Optional default 0 Index to start looking for a match |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
index of first found match, or -1 if no match
String.prototype.listFindNoCase=function( val, startFrom, delimiter, qualifier )
returns the index of a value in a list, ignoring case
| val | String value to search for |
| startFrom | Optional default 0 Index to start looking for a match |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
index of first found match, or -1 if no match
String.prototype.listFirst=function( delimiter, qualifier )
returns the first value of a list.
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
the first value of list
String.prototype.listLast=function( delimiter, qualifier )
returns the last value of a list.
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string Returns: the last value of list |
String.prototype.listAt=function( position, delimiter, qualifier )
returns the list value at a specific location, or “”.
| position | 0-based position |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String that is on both sides of values in the string |
String.prototype.listLen=function( delimiter )
returns the length of a list
| delimiter | Optional default ‘,’ String delimiter between values |
number of values in this string
String.prototype.listMakeUnique=String.prototype.listGetUnique=function( delimiter )
returns new list (string) with each item represented only once
| delimiter | Optional, default “,” String delimiter to append to this string before val. If this string is empty, or currently ends with delimiter, delimiter will not be appended. returned string |
String.prototype.listMakeUniqueNoCase=function( delimiter )
returns new list (string) with each item represented only once, regardless of case. If an item appears more than once in different upper/lower case, only the first occurance is kept.
| delimiter | Optional, default “,” String delimiter to append to this string before val. If this string is empty, or currently ends with delimiter, delimiter will not be appended. |
String.prototype.listQualify=function( symbol, delimiter, qualifier )
returns new list (string) with each item surrounded by a qualifying symbol
| symbol | Optional, default ‘ (single quote) |
| delimiter | Optional, default “,” The delimiter for this list |
| qualifier | Optional, default null Current qualifier for this list |
String.prototype.listSame=function( list, delimiter )
returns true if the provided list contains the smae elements as this list regardless of order. Both lists must use the same qualifier and delimiter
| list | list to compare to this one |
| delimiter | Optional default ‘,’ String delimiter between values |
String.prototype.listSameNoCase=function( list, delimiter )
returns true if the provided list contains the smae elements as this list regardless of order. Both lists must use the same qualifier and delimiter
| list | list to compare to this one |
| delimiter | Optional default ‘,’ String delimiter between values |
String.prototype.listSort=function( sortFunc, delimiter, qualifier )
returns a copy of this list sorted by the supplied sort function
| sortFun | Optional, default String.compareAlpha A function that takes two strings and returns -1, 0, or 1. If null the default Array sort is used. This function will be passed to Array.sort(). The String.compare* functions are easy plugins for this |
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String remove from both sides of each item |
This function converts the string list into an array of string items, sorts the array with sortFunc, and returns the array converted back into a string list.
String.prototype.listToArray=function( delimiter, qualifier )
returns an array of the items in this list
| delimiter | Optional default ‘,’ String delimiter between values |
| qualifier | Optional, default null String remove from both sides of each item |
String.prototype.toFixedWidth=function( count, pad, placeHolder, truncateFrom )
returns this string padded/truncated to the specified length
| count | number of characters to return. If this is 0 or negative an empty string will be returned |
| pad | Optional, default “ “ Character to add to the right side of the string to pad to the fixed width |
| placeHolder | Optional, default undefined If defined, this string will be used as the placeholder for text removed to make the string fit the the fixed length. The length of this string is subtracted from count so that the resulting string will not exceed count |
| truncateFrom | Opitional, default “end” This sets where the placholder will be placed in the string and from where characters will be removed. Valid values are “start”, “middle” and “end” |
returns a string forced to count length, truncating or padding as necessary
var delim = " | ";
var str = "Description".toFixedWidth(15) + delim + "Price".toFixedWidth(5) + "\n";
data.forEach(function(row){
str += row.desc.toFixedWidth(15," ","...") + delim
+ "$" + String(row.price).toFixedWidth(4)
})
Converts a JSON (http://www.json.org) string into an object
| reviver | Option, default date parser If specified, this function will be called called with (key,value) for every value in the generated object. This can be used to “revive” custom serialized values embedded in JSON. The default reviver restores dates in this format: “\/Date(1269727815826)\/” format, which is the format Object.toJson uses. |
Number String Array or Object contained in the JSON text
SyntaxError if not properly formatted
Adapted from http://code.google.com/p/json-sans-eval/
This function expects strings to be properly formatted. In particular watch out for property names, they must be quoted.
Bad:
{name:"bob"}
Good:
{"name":"bob"}
String.prototype.right=function( count )
returns the right side of a string
| count | number of characters to return |
The right count characters of string
String.prototype.repeat=function( count, delimiter, qualifier )
returns a copy of this string repeated count times
| count | number of times to copy the provided string |
| delimiter | Optional, default null string to put between each copy of the string. This will not be placed at the ent of the returned string |
| qualifier | Optional, default null string to put before and after each copy of the string |
String.prototype.splitCap=function splitCap( everyCap )
returns an array of the “words” in this string as delimited by Capital letters
| everyCap | Optional, default false Normally groups of capital letters are treated as one term, i.e “personID” splits to [“person”,”ID”]. With this set to true, every capital letter will start a term such that “personID” splits to [“person”,”I”,”D”] Example: |
"camelCasedProperty".splitCap(); //returns ["camel","Cased","Property"]
String.prototype.startsWith = function( str, caseSensitive )
returns true if this string starts with supplied string
| str | string to match |
| caseSensitive | Optional, default false Should the match be case sensitive? |
Myna.println(“BobDobb”.startsWith(“bob”))//prints true Myna.println(“BobDobb”.startsWith(“bob”,true))//prints false
String.prototype.titleCap=function()
Capitalizes the first letter of every word in string
text with the first letter of every word captialized.
String.prototype.trim=function()
returns a new string with beginning and trailing whitespace removed
String.prototype.trimIndent=function()
returns a new string with the initial white space on each line trimmed
This is useful for out-denting the entire string in situations where every line starts with the same unwanted whitespace. This is automatically applied to ejs blocks so that they can be indented with the code without adding unwanted whitespace to the string.
The string must start with an initial return (\n) followed by the regular whitespace (spaces and tabs) to replace.
var offsetString = "\n\t\tline1\n\t\tline2\n\t\t\tsubline a\n\t\tline3";
Myna.print("before<br><pre>" + offsetString + "</pre>")
Myna.print("after<br><pre>" + offsetString.trimIndent() + "</pre>")
String.prototype.unEscapeHtml=function( chars )
reverses the replacements in escapeHtml
| chars | Optional default <htmlEscapeChars> string of characters to restore. Leave this undefined to use the same set of characters as escapeHtml Returns: converted string |
$req.data,<$req.rawData>,<escapeHtml>
String.prototype.hashCode=function()
returns java.lang.String.hasCode() for this string
The Java String object provides a method for quickly creating a unique numeric hash value. This is useful for creating hash keys for lookup or equality comparisons or any other non-cryptographic uses.
for cryptographic uses see toHash
String.prototype.hashEquals=function( hash )
Returns true if the plaintext password matches the encrypted password
| hash | hash previously created with <String.hash> |
true if this string matches hash
One way hashes like those created by <String.hash> cannot be decrypted. However, you can encrypt a possible match and compare the hashes. Because of the salt in the hashes produced by <String.hash>, equivalent hashes won’t look the same, but this function can compare them.
String.prototype.toHash=function( urlSafe )
Returns a copy of this string encrypted with a strong one-way hash in base64 format.
| urlSafe | Optional, default false If true, then the characters + and / and = will be replaced with |
Encrypted password string in only printable characters.
This function encrypts the supplied text with a one-way algorithm so that it can never be converted back to the original text. This can be any text but it makes the most sense for passwords. Although you can’t tell what the original text is, you can compare the encrypted string to a plaintext string to see if they match. See String.hashEquals.
For extra security, each hash includes a salt; a string characters appended to the text to force it to be unique. This way even if an attacker can figure out that his/her password of “bob” = “tUhTivKWsIKE4IwVX9s/wzg1JKXMPU+C”, he or she will not be able to tell if any of the other hashes equal “bob”. This makes a brute force dictionary attack much more difficult.
<%="bob".toHash()%><br>
<%="bob".toHash()%><br>
<%="bob".toHash()%><br>
<%="bob".toHash()%><br>
..prints something like
tUhTivKWsIKE4IwVX9s/wzg1JKXMPU+C
M0y5EgZVG3iW2N5k2ipHp7x7JtvJYGu5
yRxnK/RlK9VeX89duVkrncQv4/vWyWGs
ca4r3Qlt51wFk/y0pv+7YazkcFtRgkoS
String.prototype.decrypt=function( password )
Returns the unencrypted string contained in this string
| password | Password used to orginally encrypt the string |
The unencrypted string contained in this string
String.prototype.encrypt=function( password )
Encrypts this string using a password.
| password | password to use for encryption. |
This function provides simple password-based encryption of string values. For more secure encryption using rotating database-backed keys see Myna.KeyStore
The encrypted string.
<%="bob".encrypt("theSecretPassword")%><br>
<%="bob".encrypt("theSecretPassword")%><br>
<%="bob".encrypt("theSecretPassword")%><br>
<%="bob".encrypt("theSecretPassword")%><br>xeM5n1ncfX2KNTLUEjZHeg==
AedyMQ5jA1rbOdQZMTq9Ag==
+Zam3Jg4YqI/5QRkcokLcQ==
LY2OAW8+xe3I5OJi/Hg+6A==
String.prototype.toXml=function()
returns an E4X XML object from this string, or throws an exception if not possible
replaces common symbols with their HTML entity equivalents
String.prototype.escapeHtml=function( string )
reverses the replacements in escapeHtml
String.prototype.unEscapeHtml=function( chars )
returns all the characters after the first count characters
String.prototype.after=function( count, caseSensitive )
returns all the characters before the last count characters
String.prototype.before=function( count )
returns the HTML/XML entity of the supplied character in &#code; format where code is the decimal ASCII code
String.charToHtmlEntity = function( c )
Static A static sort function that will compare two strings by lexigraphical order.
String.compareAlpha = function( a, b )
Static A case-insensitive version of String.compareAlpha
String.compareAlphaNoCase = function( a, b )
Static A descending version of compareAlpha.
String.compareAlphaReverse = function( a, b )
Static A case-insensitive version of String.compareAlphaReverse
String.compareAlphaReverseNoCase = function( a, b )
Static A static sort function that will compare two strings in a natural way.
String.compareNatural = function( a, b )
Static A case-insensitive version of String.compareNatural
String.compareNaturalNoCase = function( a, b )
Static A descending version of compareNatural.
String.compareNaturalReverse = function( a, b )
Static A case-insensitive version of String.compareNaturalReverse
String.compareNaturalReverseNoCase = function( a, b )
Static A static sort function that will compare two strings by lexigraphical order.
String.compareNumeric = function( a, b )
Static A descending version of compareNumeric.
String.compareNumericReverse = function( a, b )
returns true if this string ends with supplied string
String.prototype.endsWith = function( str, caseSensitive )
returns string with symbols that might be interpreted as regex escaped
String.prototype.escapeRegex=function( string )
returns string with symbols that might be interpreted as JavaScript escaped
String.prototype.escapeJs=function()
returns a string with parameters replaced
String.prototype.format=function( values )
returns java Iterator that produces a line at a time for this string
String.prototype.getLineIterator = function()
Static returns the chatacter representation of the supplied HTML/XML entity
String.htmlEntityToChar = function( e )
returns the left side of a string
String.prototype.left=function( count )
returns new list (string) with value appended (does not modify original string).
String.prototype.listAppend=function( val, delimiter, qualifier )
returns new list (string) with value appended, if not already in list
String.prototype.listAppendUnique=function( val, delimiter, qualifier )
returns new list (string) with value appended, if not already in list, ignoring case
String.prototype.listAppendUniqueNoCase=function( val, delimiter, qualifier )
returns this list minus the first element.
String.prototype.listAfter=function( delimiter, qualifier )
returns this list minus the last element.
String.prototype.listBefore=function( delimiter )
returns true if list contains the value.
String.prototype.listContains=function( val, delimiter, qualifier )
returns true if list contains the value, ignoring case.
String.prototype.listContainsNoCase=function( val, delimiter, qualifier )
returns the index of a value in a list
String.prototype.listFind=function( val, startFrom, delimiter, qualifier )
returns the index of a value in a list, ignoring case
String.prototype.listFindNoCase=function( val, startFrom, delimiter, qualifier )
returns the first value of a list.
String.prototype.listFirst=function( delimiter, qualifier )
returns the last value of a list.
String.prototype.listLast=function( delimiter, qualifier )
returns the list value at a specific location, or “”.
String.prototype.listAt=function( position, delimiter, qualifier )
returns the length of a list
String.prototype.listLen=function( delimiter )
returns new list (string) with each item represented only once
String.prototype.listMakeUnique=String.prototype.listGetUnique=function( delimiter )
returns new list (string) with each item represented only once, regardless of case.
String.prototype.listMakeUniqueNoCase=function( delimiter )
returns new list (string) with each item surrounded by a qualifying symbol
String.prototype.listQualify=function( symbol, delimiter, qualifier )
returns true if the provided list contains the smae elements as this list regardless of order.
String.prototype.listSame=function( list, delimiter )
returns true if the provided list contains the smae elements as this list regardless of order.
String.prototype.listSameNoCase=function( list, delimiter )
returns a copy of this list sorted by the supplied sort function
String.prototype.listSort=function( sortFunc, delimiter, qualifier )
returns an array of the items in this list
String.prototype.listToArray=function( delimiter, qualifier )
returns this string padded/truncated to the specified length
String.prototype.toFixedWidth=function( count, pad, placeHolder, truncateFrom )
returns the right side of a string
String.prototype.right=function( count )
returns a copy of this string repeated count times
String.prototype.repeat=function( count, delimiter, qualifier )
returns an array of the “words” in this string as delimited by Capital letters
String.prototype.splitCap=function splitCap( everyCap )
returns true if this string starts with supplied string
String.prototype.startsWith = function( str, caseSensitive )
Capitalizes the first letter of every word in string
String.prototype.titleCap=function()
returns a new string with beginning and trailing whitespace removed
String.prototype.trim=function()
returns a new string with the initial white space on each line trimmed
String.prototype.trimIndent=function()
returns java.lang.String.hasCode() for this string
String.prototype.hashCode=function()
Returns true if the plaintext password matches the encrypted password
String.prototype.hashEquals=function( hash )
Returns a copy of this string encrypted with a strong one-way hash in base64 format.
String.prototype.toHash=function( urlSafe )
Returns the unencrypted string contained in this string
String.prototype.decrypt=function( password )
Encrypts this string using a password.
String.prototype.encrypt=function( password )
returns a new java.lang.String of this string
String.prototype.toJava=function()
returns an E4X XML object from this string, or throws an exception if not possible
String.prototype.toXml=function()
returns an org.w3c.dom.Document object from this string, or throws an exception if not possible
String.prototype.toXmlDoc=function()
returns a URL encoded version of this string
String.prototype.escapeUrl=function()
returns an interator object for looping one line at a time over the file without loading the entire file into memory.
Myna.File.prototype.getLineIterator= function()
Converts the this object to JSON (http://www.json.org)
Object.prototype.toJson=function( indent )