JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT match() METHOD

The match() method searches a string for a specified match. If a match is found, it returns the match value else it returns null.

Please note that the match() method is case sensitive. The match() method takes the compulsory tosearchfor as it's argument.

The general format is:

string.match(tosearchfor);

Example:

<script type="text/javascript">

var string="Career Guidance";

document.write(string.match("reer"));

</script>

The above will output:



The match() method is extremely useful to test a string for a match and to perform different actions depending on whether the match was found or not as below:

<script type="text/javascript">

var string="Career Guidance";

if(string.match("reer"))
{
do this;
}
else
{
do that;
}

</script>

See Also:

anchor() big()
blink() bold()
charAt() charCodeAt()
concat() fixed()
fontcolor() fontsize()
fromCharCode() indexOf ()
italics () lastIndexOf()
link() match()
replace () search()
slice() small()
split() strike()
sub() substr()
substring() sup()
toLowerCase() toUpperCase()
toSource() valueOf ()

Home | Privacy Policy | Terms Of Use | Contact Us