replaceRE: Regex loop issues with regex tested on regex101

  1. The arguments to replaceRE are in the wrong sequence.

    replaceRE PATTERN REPLACEMENT INPUT [LIMIT]

  2. The regex patterns are easier to create and understand when written as string literals (surround pattern with backticks instead of quotation marks).

  3. You can simplify your pattern like this:

    `(?s)\x60{3}ad-(.+)\ntitle:\s*(.+?)\n(.+)\x60{3}`
    
1 Like