JavaScript RegExp +Quantifier

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

n+ Quantifier matches any string that contains at least onenoccurrence of the specified character.

Syntax

new RegExp("n+")

Or, more simply:

/n+/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the + quantifier.


Examples

Example 1

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

var str="Hellooo World! Hello Example!"; var patt1=/o+/g;

Below,the markedtext shows where the expression is matched:

Hellooo World! Hello Runoob!

Try it Yourself »

Example 2

Perform a global search for at least one word character:

var str="Hellooo World! Hello Example!"; var patt1=/\w+/g;

Below,the markedtext shows where the expression is matched:

Hellooo World! Hello Example!

Try it Yourself »


RegExp 对象参考手册JavaScript RegExp Object Other Extensions