adrien-dufond / manmaru.stringutil

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MANMARU STRINGUTIL JS

Inspired from CASA Lib / AS 2.0 (v.10/06/08) - Aaron Clinger, David Nelson

manmaru.stringutil.js :
Javascript utilities for manipulating and searching strings.

functions list :
addAt(source, position, addition) ->
Adds characters at a specific index
@param source: String to add characters to
@param position: Position in which to add characters
@param addition: String to add
@return String with characters added

contains(source, search) ->
Determines if string contains search string
@param source: String to search in
@param search: String to search for
@return Returns the frequency of the search term found in source string

getNumbersFromString(source) ->
Removes all non numeric characters from string
@param source: String to return numbers from
@return String containing only numbers

getUniqueCharacters(source) ->
Extracts all the unique characters from a source String
@param source: String to find unique characters within
@return String containing unique characters from source String

remove(source, remove) ->
Removes characters from a source string
@param source: String to remove characters from
@param remove: String describing characters to remove
@return String with characters removed

removeAt(source, position) ->
Removes a character at a specific index
@param source: String to remove character from
@param position: Position of character to remove
@return String with character removed

removeNumbersFromString(source) ->
Removes all numeric characters from string
@param source: String to remove numbers from
@return String with numbers removed

removeWhitespace(source) ->
Removes tabs, linefeeds, carriage returns and spaces from string
@param source: String to remove whitespace from
@return String with whitespace removed

replace(source, remove, replace) ->
Replaces target characters with new characters
@param source: String to replace characters from
@param remove: String describing characters to remove
@param replace: String to replace removed characters
@return String with characters replaced

replaceAt(source, position, replace) ->
Replaces a character at a specific index with new characters
@param source: String to replace characters from
@param position: Position of character to replace
@param replace: String to replace removed character
@return String with character replaced

toTitleCase(source) ->
Transforms source string to per word capitalization.
@param source: String to return as title cased.
@return String with capitalized words.

urlValue(name, string) ->
Get value of string with URLFormat
@param name Example: &var1=mi_var1&var2=mi_var2&var3=mi_var3
StringUtil.urlValue('var2')
@return String mi_var2

urlFriendly(source, max) ->
Transform source string in url string format
@param source: String to return as url format
@return string

pathVars(str, number_return) ->
Transform source url string in array
@param source: url string to return in array
@return array

utf8Encode(source) ->
UTF8 Encode
@param source: string to encode
@return encoded UTF8 String

utf8Decode(source) ->
UTF8 Decode
@param source: string to Decode
@return Decode UTF8 String

lnToBr(source) ->
Transform \n to br
@param source: String
@return String

brToLn(source) ->
Transform br to \n
@param source: String
@return String


How to use:
StringUtil.functionName("param");

Example of use :
var testString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit";
console.log(StringUtil.removeWhitespace(testString));
return -> Loremipsumdolorsitamet,consecteturadipiscingelit

About


Languages

Language:JavaScript 100.0%