public interface JSStringFunctions extends JSObjectFunctions
hasOwnProperty| Modifier and Type | Method and Description |
|---|---|
JSString |
charAt(JSNumber position)
function charAt(position) get the nth character from a string.
|
JSNumber |
charCodeAt(JSNumber position)
function charCodeAt(position) get the nth character code from a string.
|
JSString |
concat(JSString value)
function concat(value1, ...) concatenate strings
|
JSNumber |
indexOf(JSString searchString,
JSNumber startPosition)
function indexOf(searchString, startPosition) search a string.
|
JSNumber |
lastIndexOf(JSString searchString,
JSNumber startPosition)
function lastIndexOf(searchString, startPosition) search a string backward.
|
JSNumber |
localeCompare(JSString otherString)
function localeCompare(otherString) compare one string to another, using locale-specific ordering.
|
JSString |
match(JSRegExp regexp)
function match(regexp) find one or more regular-expression matches
|
JSString |
replace(JSRegExp regexp,
JSString replaceValue)
function replace(regexp, replaceValue) replace substring(s) matching a regular expression.
|
JSNumber |
search(JSRegExp regexp)
function search(regexp) search for a regular expression
|
JSString |
slice(JSNumber start,
JSNumber end)
function slice(start, end) extract a substring.
|
JSArray |
split(JSString separator,
JSNumber limit)
function split(separator, limit) break a string into an array of strings.
|
JSString |
substring(JSNumber from,
JSNumber to)
function substring(from, to) return a substring of a string.
|
JSString |
toLocaleLowerCase()
function toLocaleLowerCase() Converts a string to lower case.
|
JSString |
toLocaleUpperCase()
function toLocaleUpperCase() Converts a string to upper case.
|
JSString |
toLowerCase()
function toLowerCase() Converts a string to lower case.
|
JSString |
toUpperCase()
function toUpperCase() Converts a string to upper case.
|
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOfJSString charAt(JSNumber position)
position - The index of the character that should be returned from string.String,
charCodeAt(),
indexOf(),
lastIndexOf()JSNumber charCodeAt(JSNumber position)
JSString concat(JSString value)
value - one or more values to be concatenated to string.StringJSNumber indexOf(JSString searchString, JSNumber startPosition)
searchString - The substring to be search within string.startPosition - Optional start index.StringJSNumber lastIndexOf(JSString searchString, JSNumber startPosition)
searchString - The substring to be search within string.startPosition - Optional start index.StringJSNumber localeCompare(JSString otherString)
Example
var string;//array of string initialised somewhere
strings.sort(function(a,b){return a.localCompare(b);});
otherString - A string to be compared, in a locale-sensitive fashion, with string.StringJSString match(JSRegExp regexp)
regexp - A RegExp object that specifies the pattern to be matched.StringJSString replace(JSRegExp regexp, JSString replaceValue)
regexp - A RegExp object that specifies the pattern to be replaced.replaceValue - A string that specifies the replacement text.StringJSNumber search(JSRegExp regexp)
regexp - A RegExp object that specifies the pattern to be searched.StringJSString slice(JSNumber start, JSNumber end)
Example
var s = "abcdefg"; s.slice(0,4); //returns "abcd" s.slice(2,4); //returns "cd" s.slice(4); //returns "efg" s.slice(3, -1); //returns "def" s.slice(3,-2); //returns "de"
start - The start index where the slice if to begin.end - Optional end index where the slice is to end.StringJSArray split(JSString separator, JSNumber limit)
Example
"1|2|3|4".split("|"); //returns ["1","2","3","4"]
"%1%2%3%4%".split("%"); //returns ["","1","2","3","4",""]
separator - The string or regular expression at which the string splitslimit - Optional value that specifies the maximum length of the returned array.StringJSString substring(JSNumber from, JSNumber to)
from - The index where to start the extraction. First character is at index 0to - Optional. The index where to stop the extraction. If omitted, it extracts the rest of the stringStringJSString toLowerCase()
String,
charAt(),
indexOf(),
lastIndexOf()JSString toLocaleLowerCase()
String,
toLocaleUpperCase()JSString toUpperCase()
String