• 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?

    • This topic was modified 5 years, 10 months ago by rdzman.
Viewing 1 replies (of 1 total)
  • Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    I want to say yes because regex is really powerful, but offhand I don’t have the solution. If faced with the same challenge I’d probably be lazy and use two rules, like you said, to get it done.

Viewing 1 replies (of 1 total)
  • The topic ‘regex with multiple matches’ is closed to new replies.