Regular Expressions 101

Community Patterns

1...45678...877

Replace second (or further) html statement in a whole code

1

Regular Expression
ECMAScript (JavaScript)

/
((?:\<[^<>]+\>\s?)?)([:]\w+(?!\w*[;]))((?:\s?\<\/[^<>]+\>)?)((?:(?:.(?!\1\2\3))*.){2})\1\2\3
/

Description

This regex replace the second tag content which has the prefix ":". If you want to replace the third, just increase the statement {1} to {2}, and so go on.

Submitted by Caio Oliveira - 10 years ago