regex with multiple matches
-
I’d like to replace multiple instances of a word, but only when it appears within
<title>...</title>tags. For example, if I want to replace “REGEX” with “PATTERN” only inside<title>...</title>and my page includes the following line:<title>A REGEX that replaces multiple REGEX instances.</title>With the following pattern:
/<title>(.*)REGEX(.*)<\/title>/And replacement string:
<title>\1PATTERN\2</title>The result just replaces the 2nd occurrence, resulting in:
<title>A REGEX that replaces multiple PATTERN instances.</title>I know that creating 2 identical entries will handle this case, but is there a way to do this with a single regex pattern?
The topic ‘regex with multiple matches’ is closed to new replies.