Alloy.builtins.string

A collection of utilities for manipulating strings. To use the string builtin library, require it with the alloy root directory in your require call. For example:

var string = require('alloy/string');
var text = '     hola, mundo   ';
Ti.API.info(string.ucfirst(string.trim(text))); // --> 'Hola, mundo'
Defined By

Methods

Alloy.builtins.string
( amount ) : String
Returns an amount formatted as a currency value. ...

Returns an amount formatted as a currency value. Uses the device settings to determine the currency symbol. On the Mobile Web platform, the currency symbol will always be dollars ('$').

Parameters

  • amount : String

    Amount to format.

Returns

  • String

    Amount formatted as a currency value.

Alloy.builtins.string
( text ) : String
Lowercases the first character in the string. ...

Lowercases the first character in the string.

Parameters

  • text : String

    String to lowercase.

Returns

  • String

    String with first character lowercased.

Alloy.builtins.string
( line ) : String
Removes leading and trailing white space from a string. ...

Removes leading and trailing white space from a string.

Parameters

  • line : String

    String to trim.

Returns

  • String

    String without leading and trailing white space.

Alloy.builtins.string
( num ) : Number
Removes trailing zeroes from a float value after the decimal point. ...

Removes trailing zeroes from a float value after the decimal point.

Parameters

  • num : Object

    Number to trim.

Returns

  • Number

    Number without trailing zeroes.

Alloy.builtins.string
( text ) : String
Capitalizes the first character in the string. ...

Capitalizes the first character in the string.

Parameters

  • text : String

    String to capitalize.

Returns

  • String

    String with first character capitalized.

Alloy.builtins.string
( url ) : String
Converts URL-encoded characters in a string to ASCII characters. ...

Converts URL-encoded characters in a string to ASCII characters. For example, the string '%38' will return '&'.

Parameters

  • url : String

    String to process.

Returns

  • String

    String with URL-encoded characters replaced with ASCII characters.

Alloy.builtins.string
( url ) : Object
Parses an URL and converts it to JSON-formatted data. ...

Parses an URL and converts it to JSON-formatted data. For example, an URL with a query string will produce a JSON object with each query field paired with its value as well as the base URL.

Parameters

  • url : String

    URL to process.

Returns

  • Object

    JSON-formatted URL data.