e_m_a_i_l_Encrypt
static
document.write
e_m_a_i_l_Encrypt
(
first
,
second
,
domain
,
extension
,
label
)
Sample for Write me:
jsbeans.string.e_m_a_i_l_Encrypt("Xmyn", "ame", "mydomain", "com", "Write me");
jsbeans.string.e_m_a_i_l_Encrypt("Xmyn", "ame", "mydomain", "com", "Write me");
- Parameters:
-
first <String>
-
second <String>
-
domain <String>
-
extension <String>
-
label <String>
- Returns:
document.write
ellipsis
static
String
ellipsis
(
str
,
length
,
[options]
)
Truncates a given string at a defined number of characters substituting last chars with a string ("..." by default. Can be overridden)
- Parameters:
-
str <String>
the string to truncate -
length <Integer>
default 10 -
[options] <JSON>
href: <String>, // an url invoked on an anchor (tag
a
), default '#' ellipsisString: <String> // the substitution for truncated string, default '...'
- Returns:
String
- a new, truncated, string
endsWith
static
void
endsWith
(
str
,
search
,
[offset]
)
Checks if a string has same characters of another string at the ending.
Optionally the comparison starts from a given {@param}
Optionally the comparison starts from a given {@param}
offset
(number of characters from the end)
- Parameters:
-
str <String>
-
search <String>
the string to search for -
[offset] <Integer>
- Returns:
void
format
static
String
format
(
str
,
args
)
Replace positional placeholder in the form
Sample 1:
{n}
where 'n' is an integer within {@param} str
Sample 1:
jsbeans.string.format('My name is {0} and my email is {1}', 'Ciccio', 'ciccio@example.com');returns 'My name is Ciccio and my email is ciccio@example.com'. Sample 2:
jsbeans.string.format('My name is {name} and my email is {email}', {name: 'Ciccio', email: 'ciccio@example.com'});returns 'My name is Ciccio and my email is ciccio@example.com'.
- Parameters:
-
str <String>
the string to format -
args <Array | JSON | arguments>
a list of replacers or an Array or a JSON. If second argument is an Object (Array or JSON), no other argument is taken in account.
- Returns:
String
- the new formatted string
fromHex
static
String
fromHex
(
str
)
Translate a string from its hexdecimal format into a human readable format
- Parameters:
-
str <String>
the string to translate
- Returns:
String
- the human readable, translated string
getFileSize
static
String
getFileSize
(
bytes
,
[decimals]
)
Transforms a number, occasionally bytes, in a human readable format with B, KB, MB, ... at the end.
- Parameters:
-
bytes <Integer>
-
[decimals] <Integer>
default 1
- Returns:
String
- a formatted, human readable, string
hexToRgb
static
Array | JSON
hexToRgb
(
hex
,
[jsonFormat]
)
Translate an hexadecimal color into its equivalent RGB (red, green, blue) format.
- Parameters:
-
hex <String>
-
[jsonFormat] <boolean>
if true the return type will be in JSON format
- Returns:
Array | JSON
- an array of int for red, green and blue OR a JSON if second argument is true.
red: <Integer>, green: <Integer>, blue: <Integer>
isEmpty
static
boolean
isEmpty
(
str
)
Checks if a string has no characters ("")
- Parameters:
-
str <String>
- Returns:
boolean
isEmptyOrNull
static
boolean
isEmptyOrNull
(
str
)
Checks if a given string has no characters or is null
- Parameters:
-
str <String>
- Returns:
boolean
isNullOrEmpty
static
boolean
isNullOrEmpty
(
str
)
Alias for
jsbeans.string.isEmptyOrNull
- Parameters:
-
str <String>
the string to check
- Returns:
boolean
parseBoolean
static
boolean
parseBoolean
(
str
,
[match]
)
Returns true if given {@param}
str
is '1', 'true' (case insensitive), 't' (case insensitive) or, eventually, any other value that matches {@param} match
- Parameters:
-
str <String>
-
[match] <String>
- Returns:
boolean
parseInt
static
Integer
parseInt
(
str
)
Safe replacer for native parseInt function
Sample:
parseInt("0q") returns 0
jsbeans.string.parseInt("0q") returns NaN
Sample:
parseInt("0q") returns 0
jsbeans.string.parseInt("0q") returns NaN
- Parameters:
-
str <String>
- Returns:
Integer
remove
static
String
remove
(
str
,
match
,
[offset]
)
Removes {@param}
match
from {@param} str
starting from {@param} offset
.
- Parameters:
-
str <String>
-
match <String>
-
[offset] <Integer>
default 0
- Returns:
String
rgbToHex
static
String
rgbToHex
(
red
,
green
,
blue
)
Translate a 3-ple RGB (red, green, blue) into hexadecimal equivalent.
Example: 255, 255, 255 is FFFFFF
Example: 255, 255, 255 is FFFFFF
- Parameters:
-
red <Integer>
-
green <Integer>
-
blue <Integer>
- Returns:
String
- the hexadeciaml equivalent
startsWith
static
void
startsWith
(
str
,
search
,
[offset]
)
Checks if a string has same characters of another string at the beginning.
Optionally the comparison starts from a given {@param}
Optionally the comparison starts from a given {@param}
offset
(number of characters from the start)
- Parameters:
-
str <String>
-
search <String>
the string to search for -
[offset] <Integer>
- Returns:
void
stripHTML
static
String
stripHTML
(
str
)
An
It removes all tags and their content returning only contained text.
innerText
functionality.It removes all tags and their content returning only contained text.
- Parameters:
-
str <String>
a string to parse, normally in HTML or XML format
- Returns:
String
- the inner text, without HTML tags
toHex
static
String
toHex
(
str
)
Translate a string into its hexdecimal format.
- Parameters:
-
str <String>
the string to translate
- Returns:
String
- the translated string
trim
static
String
trim
(
str
)
A common issue: removes blanks from the beginning and the ending of a given string.
- Parameters:
-
str <String>
the string to trim
- Returns:
String
- a new trimmed string
trimLeft
static
String
trimLeft
(
str
)
Removes blanks fron the beginning of a given string
- Parameters:
-
str <String>
the string to trim
- Returns:
String
trimRight
static
String
trimRight
(
str
)
Removes blanks fron the ending of a given string.
- Parameters:
-
str <String>
the string to trim
- Returns:
String