• ♡ Sponsor

    replace

    #Regex

    Performs a regular expression search and replace.

    @{  text | replace (regex, replace) }
    

    Parameters

    regex
    A valid regular expression, wrapped in delimiters like "/pattern/".
    replace
    The replacement string. Note that you can make use of backreferences like $1 to $n as described here.

    Note that you will have to use double backslashes \\ to escape reserved characters in regex patterns.

    Example

    The following example will first parse all Markdown in a variable called text and then wrap everything enclosed with double curly brackets in a <div>:

    @{ text | 
        markdown |
        replace (
            '/\\{\\{(.*?)\\}\\}/is', 
            '<div class="wrapper">$1</div>'
        ) 
    }
    

    Related

    Pipe  ⁄
    match — Pipe

    Performs a Regex match and returns 1 if the given pattern matches and 0 if not.

    Toolbox  ⁄
    newPagelist — Toolbox

    Creates a new pagelist object. The current pagelist will be replaced. A foreach loop can be used to iterate over the pagelist object. This method does not have any output. To only update the configuration of the current pagelist, without resetting all other parameters, the ...

    Toolbox  ⁄
    pagelist — Toolbox

    Modifies the currently defined pagelist pagelist object. Only specified options will be changed, all others will be preserved. To restore a default pagelist and reset all options, the newPagelist method can be used.

    Objects  ⁄
    Pagelist — Objects

    The pagelist contains by default all pages which are not hidden and therefore has no defined type. Changing the pagelist type to one of the following available types will update the selection of pages accordingly. The main purpose of this object is to provide an easy way of ...

    • Automad
    • Developer Guide
    • Building Themes
    • Template Language
    • Pipe
    • replace
    Discuss
    Packages
    Release Notes
    Support
    Terms of Use
      Become a Sponsor
      GitHub
      Twitter
      Facebook
      Instagram
      2013-2023 by Marc Anton Dahmen
    Released under the MIT license

    A faceless machine, creating one's portrait in the internet.
  • Automad
  • Getting Started
  • System
  • User Guide
  • Developer Guide
  • Headless Mode
  • Discuss
  • Packages
  • Developer Guide ←
  • Building Themes ←
  • Template Language ←
  • Pipe
  • ceil
  • dateFormat
  • def
  • escape
  • findFirstImage
  • findFirstParagraph
  • floor
  • markdown
  • match
  • replace
  • round
  • sanitize
  • shorten
  • stripEnd
  • stripStart
  • stripTags
  • strlen
  • strtolower
  • strtoupper
  • ucwords