module Jekyll::RegexCaptureFilter

Adds a 'regex_capture' filter to Liquid. Performs a regular expression match on the provided string and returns the capture as an array. Example usage: {{ html | regex_capture: 'id=“(+)”' | first }}

Public Instance Methods

regex_capture(str, regex) click to toggle source
# File lib/regex_capture_filter.rb, line 11
def regex_capture(str, regex)
  match = /#{regex}/.match(str)
  match ? match.captures : []
end