StringUtil
Kind of class: | public class |
---|---|
Package: | org.casalib.util |
Inherits from: | none |
Version: | 02/10/09 |
Author: | Aaron Clinger, Mike Creighton, David Nelson |
Classpath: | org.casalib.util.StringUtil |
File last modified: | Tuesday, 10 February 2009, 18:18:22 |
Utilities for manipulating and searching Strings.
Summary
Constants
- WHITESPACE : String
Class properties
- SMALL_WORDS : Array
Class methods
- toTitleCase (source:String, lowerCaseSmallWords:Boolean = true) : String
- Transforms source String to title case.
- isPunctuation (source:String, allowSpaces:Boolean = true) : Boolean
- Determines if String is only comprised of punctuation characters (any character other than the letters or numbers).
- isUpperCase (source:String) : Boolean
- Determines if String is only comprised of upper case letters.
- isLowerCase (source:String) : Boolean
- Determines if String is only comprised of lower case letters.
- indexOfUpperCase (source:String, startIndex:uint = 0) : int
- Searches the String for an occurrence of an upper case letter.
- indexOfLowerCase (source:String, startIndex:uint = 0) : int
- Searches the String for an occurrence of a lower case letter.
- getNumbersFromString (source:String) : String
- Returns all the numeric characters from a String.
- getLettersFromString (source:String) : String
- Returns all the letter characters from a String.
- contains (source:String, search:String) : uint
- Determines if String contains search String.
- trimLeft (source:String, removeChars:String = StringUtil.WHITESPACE) : String
- Strips whitespace (or other characters) from the beginning of a String.
- trimRight (source:String, removeChars:String = StringUtil.WHITESPACE) : String
- Strips whitespace (or other characters) from the end of a String.
- trim (source:String, removeChars:String = StringUtil.WHITESPACE) : String
- Strips whitespace (or other characters) from the beginning and end of a String.
- removeExtraSpaces (source:String) : String
- Removes additional spaces from String.
- removeWhitespace (source:String) : String
- Removes tabs, linefeeds, carriage returns and spaces from String.
- remove (source:String, remove:String) : String
- Removes characters from a source String.
- replace (source:String, remove:String, replace:String) : String
- Replaces target characters with new characters.
- removeAt (source:String, position:int) : String
- Removes a character at a specific index.
- replaceAt (source:String, position:int, replace:String) : String
- Replaces a character at a specific index with new characters.
- addAt (source:String, position:int, addition:String) : String
- Adds characters at a specific index.
- getUniqueCharacters (source:String) : String
- Extracts all the unique characters from a source String.
Constants
WHITESPACE
public static const WHITESPACE:String = ' \n\t\r'
(read)
Class properties
SMALL_WORDS
public static SMALL_WORDS:Array = new Array('a', 'an', 'and', 'as', 'at', 'but', 'by', 'en', 'for', 'if', 'in', 'of', 'on', 'or', 'the', 'to', 'v', 'via', 'vs')
(read,write)
Class methods
addAt
public static function addAt (
source:String,
position:int,
addition:String) : String
Adds characters at a specific index.
Parameters:
source :
String to add characters to.
position:
Position in which to add characters.
addition:
String to add.
Returns:
- String with characters added.
contains
public static function contains (
source:String,
search:String) : uint
Determines if String contains search String.
Parameters:
source:
String to search in.
search:
String to search for.
Returns:
- Returns the frequency of the search term found in source String.
getLettersFromString
public static function getLettersFromString (
source:String) : String
Returns all the letter characters from a String.
Parameters:
source:
String to return letters from.
Returns:
- String containing only letters.
getNumbersFromString
public static function getNumbersFromString (
source:String) : String
Returns all the numeric characters from a String.
Parameters:
source:
String to return numbers from.
Returns:
- String containing only numbers.
getUniqueCharacters
public static function getUniqueCharacters (
source:String) : String
Extracts all the unique characters from a source String.
Parameters:
source:
String to find unique characters within.
Returns:
- String containing unique characters from source String.
indexOfLowerCase
public static function indexOfLowerCase (
source:String,
startIndex:uint = 0) : int
Searches the String for an occurrence of a lower case letter.
Parameters:
source:
String to search for a lower case letter.
Returns:
- The index of the first occurrence of a lower case letter or
-1
.
indexOfUpperCase
public static function indexOfUpperCase (
source:String,
startIndex:uint = 0) : int
Searches the String for an occurrence of an upper case letter.
Parameters:
source:
String to search for a upper case letter.
Returns:
- The index of the first occurrence of a upper case letter or
-1
.
isLowerCase
public static function isLowerCase (
source:String) : Boolean
Determines if String is only comprised of lower case letters.
Parameters:
source:
String to check if lower case.
Returns:
- Returns
true
if String is only lower case characters; otherwisefalse
.
isPunctuation
public static function isPunctuation (
source:String,
allowSpaces:Boolean = true) : Boolean
Determines if String is only comprised of punctuation characters (any character other than the letters or numbers).
Parameters:
source :
String to check if punctuation.
allowSpaces:
Indicates to count spaces as punctuation
true
, or not to false
.Returns:
- Returns
true
if String is only punctuation; otherwisefalse
.
isUpperCase
public static function isUpperCase (
source:String) : Boolean
Determines if String is only comprised of upper case letters.
Parameters:
source:
String to check if upper case.
Returns:
- Returns
true
if String is only upper case characters; otherwisefalse
.
remove
public static function remove (
source:String,
remove:String) : String
Removes characters from a source String.
Parameters:
source:
String to remove characters from.
remove:
String describing characters to remove.
Returns:
- String with characters removed.
removeAt
public static function removeAt (
source:String,
position:int) : String
Removes a character at a specific index.
Parameters:
source :
String to remove character from.
position:
Position of character to remove.
Returns:
- String with character removed.
removeExtraSpaces
public static function removeExtraSpaces (
source:String) : String
Removes additional spaces from String.
Parameters:
source:
String to remove extra spaces from.
Returns:
- String with additional spaces removed.
removeWhitespace
public static function removeWhitespace (
source:String) : String
Removes tabs, linefeeds, carriage returns and spaces from String.
Parameters:
source:
String to remove whitespace from.
Returns:
- String with whitespace removed.
replace
public static function replace (
source:String,
remove:String,
replace:String) : String
Replaces target characters with new characters.
Parameters:
source :
String to replace characters from.
remove :
String describing characters to remove.
replace:
String to replace removed characters.
Returns:
- String with characters replaced.
replaceAt
public static function replaceAt (
source:String,
position:int,
replace:String) : String
Replaces a character at a specific index with new characters.
Parameters:
source :
String to replace characters from.
position:
Position of character to replace.
replace :
String to replace removed character.
Returns:
- String with character replaced.
toTitleCase
public static function toTitleCase (
source:String,
lowerCaseSmallWords:Boolean = true) : String
Transforms source String to title case.
Parameters:
source :
String to return as title cased.
lowerCaseSmallWords:
Returns:
- String with capitalized words.
trim
public static function trim (
source:String,
removeChars:String = StringUtil.WHITESPACE) : String
Strips whitespace (or other characters) from the beginning and end of a String.
Parameters:
source :
String to remove characters from.
removeChars:
Characters to strip (case sensitive).
Returns:
- String with characters removed.
trimLeft
public static function trimLeft (
source:String,
removeChars:String = StringUtil.WHITESPACE) : String
Strips whitespace (or other characters) from the beginning of a String.
Parameters:
source :
String to remove characters from.
removeChars:
Characters to strip (case sensitive).
Returns:
- String with characters removed.
trimRight
public static function trimRight (
source:String,
removeChars:String = StringUtil.WHITESPACE) : String
Strips whitespace (or other characters) from the end of a String.
Parameters:
source :
String to remove characters from.
removeChars:
Characters to strip (case sensitive).
Returns:
- String with characters removed.