string.replace()

Javascript String replace

JavaScript String replace() method searches the occurrences of a given string pattern and replace it with a given substring. The String replace() method returns the new modified string and it will not affect the value of the original string itself. The search argument can be a Regular Expression or a string, and the replacement can be either a string or a JavaScript function.

Syntax

example

The above code output as "Test Value"

Full Source

string.charAt()

Javascript String charAt

JavaScript String charAt() method returns the specified character from a string of the given index number. The index starts from 0 to string.length - 1. If the given index value is out of range, it will returns an empty string.

Syntax

Source

The above code will return "a".

string.charCodeAt()

JavaScript String charCodeAt() method returns the numeric Unicode value of specified character from a string of the given index number. If the given index value is out of range, it will returns an empty string.

Syntax

Full Source

The above code will return 97, that is the numeric Unicode value of "a" is 97.

string.match()

Javascript String match

JavaScript String match() searches a string for a match against a regular expression and returns an array. Each element of the array contains the string of each match that is found.

Syntax

example

The above code will display "kle,kle", because there are two occurrences of "kle" in the "twinkle twinkle little star"

string match() with wildcard

You can use javascript string match(). Periods are single wildcard characters

example

Full Source