Returns the number of times the value of a second character expression occurs within the first character expression.

Syntax

JSV_occurs(expS1, expS2)

Prototype

expS1.occurs(expS2)

Returns

The function occurs returns zero if the string expS2 isn't found in the the string expS1; otherwise, it returns the number of times expS2 occurs within expS1.

Parameters

The occurs function uses the following arguments.

Argument Description
expS1 This character expression is searched for occurrences of the second character expression expS2.
expS2 The character expression for which to search in expS1.

Remarks

n/a

Dependencies

JSV_isEmpty, JSV_replace

Example

The following lines of code

var testString1 = "Quiet feet make little noise on sleek ice", testString2 = "e";
document.write( testString2.bold() + 
    " occurs " +
    JSV_occurs(testString1,testString2) + 
    " times in " + 
    testString1.bold() );

produce