stringUtil

(esrith/amos/core/stringUtil)

String utility class extension.

Type Description
alphaNumericStr String

Return upper number, lower and upper case english character string.

englishKeyboardStr String

Return all character string on the english keyboard.

lowerCaseStr String

Return lower case english character string - "abcdefghijklmnopqrstuvwxyz".

lowerCaseStr String

Return upper case english character string - "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

lowerCaseStr String

Return upper lower and upper case english character string.

numericStr String

Return numeric string - "0123456789".

specialStr String

Return special character string on the english keyboard.

Return type Description
format(formatitems) String

Format string using numbered replacement fields {number}. The replacement strings will replace the numbered replacement fields.

isNotEmpty(str) Boolean

Check if string is not empty.

isNullOrEmpty(str) Boolean

Check if string is null or empty.

JSONformat(formatitem) String

Format string using named replacement fields {key}. The replacement keys are matched and replacement values will replace the named replacement fields.

replaceAt(strindexcharacter) String

Replace character in the string at specified index.

reverse(str) String

Reverse original string.

Properties Detail
<String>
alphaNumericStr

Return upper number, lower and upper case english character string.

<String>
englishKeyboardStr

Return all character string on the english keyboard.

<String>
lowerCaseStr

Return lower case english character string - "abcdefghijklmnopqrstuvwxyz".

<String>
lowerCaseStr

Return upper case english character string - "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

<String>
lowerCaseStr

Return upper lower and upper case english character string.

<String>
numericStr

Return numeric string - "0123456789".

<String>
specialStr

Return special character string on the english keyboard.

Methods Detail
<String>
format
(
  • format
  • items
)

Format string using numbered replacement fields {number}. The replacement strings will replace the numbered replacement fields.

Parameters
  • <String> format Required

    String with replacement fields in form of {number}.

  • <String> items Required

    String for replacement. If more than one replacements, split them using comma (,) as shown in example below.

Sample:
 stringUtil.format('{0} is dead, but {1} is alive! {0} {2}', 'ASP', 'ASP.NET');
         //output : ASP is dead, but ASP.NET is alive! ASP {2}
<Boolean>
isNotEmpty
(
  • str
)

Check if string is not empty.

Parameters
  • <String> str Required

    string to check.

<Boolean>
isNullOrEmpty
(
  • str
)

Check if string is null or empty.

Parameters
  • <String> str Required

    string to check.

<String>
JSONformat
(
  • format
  • item
)

Format string using named replacement fields {key}. The replacement keys are matched and replacement values will replace the named replacement fields.

Parameters
  • <String> format Required

    String with replacement fields in form of {key}.

  • <Object> item Required

    Object containing keys and corresponding replacement values in form of JSON.

Sample:
 stringUtil.JSONFormat('My name is {name}, I am {age} years old.', {name:'Bob', age:22});
         //output : My name is Bob, I am 22 years old.
<String>
replaceAt
(
  • str
  • index
  • character
)

Replace character in the string at specified index.

Parameters
  • <String> str Required

    source.

  • <Number> index Required

    position to replace.

  • <String> character Required

    replacement string.

Sample:
 stringUtil.replaceAt('Hello World!', 2, '123');
         //output : He123lo World
<String>
reverse
(
  • str
)

Reverse original string.

Parameters
  • <String> str Required

    string to reverse.