Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RegExp + quantifier

JavaScript RegExp + quantifier

RegExp Object Reference The JavaScript RegExp object


Definition and Usage

nThe + quantifier matches a string containing at least one n .

Syntax

new RegExp("

n

+")

Or a simpler way:

/

n

+/


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the + quantifier.


Example

Example 1

Perform a global search for at least one "o":

var

str

=

"

Hellooo World! Hello Runoob!

"

;

var

patt1

=/

o

+/

g

;

The text marked below shows where the expression found matches:

Hell

ooo

W

o

rld! Hell

o

Run

oo

b!

Try it »

Example 2

Perform a global search for at least one word character:

var

str

=

"

Hellooo World! Hello Runoob!

"

;

var

patt1

=/\

w

+/

g

;

The text marked below shows where the expression found matches:

Hellooo World

!

Hello Runoob

!

Try it »


RegExp Object Reference The JavaScript RegExp object