Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Possible Duplicate:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

Possible Duplicate:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

Possible Duplicate:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

insert duplicate link
Source Link

Possible Duplicate:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

Possible Duplicate:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

added 4 characters in body
Source Link
sachleen
  • 31.2k
  • 8
  • 82
  • 75

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } For For example:

`getMatchesgetMatches("cats and rats", /(c|r)ats/);`; 

should return the array [[0, 3], [9, 12]][[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } For example:

`getMatches("cats and rats", /(c|r)ats/);` 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

In Javascript, is it possible to find the starting and ending indices of all substrings within a string that match a regular expression?

Function signature:

function getMatches(theString, theRegex){ //return the starting and ending indices of match of theRegex inside theString //a 2D array should be returned } 

For example:

getMatches("cats and rats", /(c|r)ats/); 

should return the array [[0, 3], [9, 12]], which represents the starting and ending indices of "cats" and "rats" within the string.

Source Link
Anderson Green
  • 32.1k
  • 70
  • 216
  • 343
Loading