Skip to content

You are here: String API

String API

The voltmx.string namespace provides static string functions that augment the functions in the String type that is available by default. For more information see, https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/string.

Note: JavaScript distinguishes between String objects and primitive string values.

String literals (denoted by double or single quotes) and strings returned from String calls in a non-constructor context (i.e., without using the new keyword) are primitive strings. JavaScript automatically converts primitive strings and String objects, making it possible to use String object methods for primitive strings. In cases where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript automatically wraps the string primitive and calls the method or performs the property lookup.

The String API contains the voltmx.string Namespace and related API elements:

Function Description
voltmx.string.containsChars Verifies if any one of the specified set of characters is available in the given string and returns a boolean value.
voltmx.string.containsOnlyGivenChars Verifies if only (and only) the specified set of characters is available in the given string and returns a boolean value.
voltmx.string.containsNoGivenChars Verifies that the input string does not contain any of the specified characters and returns a boolean value.
voltmx.string.endsWith Returns a boolean value indicating if the source string ends with the specified string.
voltmx.string.equalsIgnoreCase Determines whether two strings contain the same data, ignoring the case of the letters in the String.
voltmx.string.isAsciiAlpha Verifies if the input string contains only ASCII alphabet characters and returns a boolean value.
voltmx.string.isAsciiAlphaNumeric Verifies if the input string contains only ASCII alphabet characters and numbers, and returns a boolean value.
voltmx.string.isNumeric Verifies if the input string contains only numeric characters, and returns a boolean value.
voltmx.string.isValidEmail Verifies if the input string is a valid email address and returns a boolean value.
voltmx.string.rep Generates a string which is equivalent to n copies of the source string concatenated together.
voltmx.string.reverse Reverses the characters in the source string.
voltmx.string.startsWith Returns a boolean value indicating if the source string begins with the specified string.
voltmx.string.trim Removes the leading and ending spaces from the source string.

Use the voltmx.string.containsChars function to check whether the specified set of characters are available in the given string. To verify that only a specified set of characters is available in the given string, use the voltmx.string.containsOnlyGivenChars function. If you want to verify that no given characters are available in the given string, use the voltmx.string.containsNoGivenChars function. You can check whether a string starts or ends with a specified string using the voltmx.string.startsWith or the voltmx.string.endsWith functions respectively. Use the voltmx.string.equalsIgnoreCase function to determine whether two strings contain the same data, ignoring the case of the letters in the String. To check whether the input string contains only ASCII alphabet characters, use the voltmx.string.isAsciiAlpha function that returns a boolean value. Use the voltmx.string.isAsciiAlphaNumeric function to verify if the input string contains only ASCII alphabet characters and numbers. The voltmx.string.isNumeric function verifies if the input string contains only numeric characters. Use the voltmx.string.isValidEmail function to verify if the specified string is a valid email address. The voltmx.string.reverse reverses the characters in the source string. Use the voltmx.string.trim to remove the leading and ending spaces from a source string.

All the functions in the Volt MX String API are in the voltmx.string namespace. The voltmx.string namespace contains functions that are deprecated and must therefore not be used in new software development. However, documentation for them is provided to help with the maintenance of legacy apps.

To view the functionality of the String API in action, download the sample application from the link below. Once the application is downloaded, build and preview the application using the Volt MX App.