-
Couldn't load subscription status.
- Fork 0
ProtoString charRange() Method
<< Back to Miscellaneous Methods
Leaving the second parameter undefined will return the range as a string.
String.charRange('A', 'Z'); // returns the alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'Passing "array" as the second parameter returns the range as an array.
String.charRange('0', '9', 'array'); // returns [0,1,2,3,4,5,6,7,8,9]Passing "object" returns the range as an object. The characters in the object can be accessed via their character code.
String.charRange('A', 'C', 'object'); // returns {u65:'A',u66:'B',u67:'C'}The charRange method can be used to produce a range of characters as a string, array, or object. It returns all characters between the start and end point, including both the start and end characters. This is a static method, so it should always be used as String.charRange(), and not as a method of a string object you created.
String.charRange(alpha, omega, type);| Parameter | Description |
|---|---|
| alpha | A string containing a single character that determines the starting point of the range. Defaults to character code 0 if left undefined. |
| omega | A string containing a single character that determines the ending point of the range. Defaults to character code 65535 if left undefined. |
| Type | A string representing the data type to be returned. Possible values are string, array, and object. Defaults to string if left undefined. |
Home • History • ProtoString • Created by Seth Clydesdale