Using JavaScript and Regular Expressions, how can I replace the third match?
For example, I want JavaScript to return this:
hello[11][22][X][44][55]'
var str = 'hello[11][22][33][44][55]';
alert( str.replace(/(\[[0-9]+\]){3}/, '[X]') );
Open in new window