module Utils::IRB::Regexp

def show_match(

Returns:
  • (String) - the formatted string with matched portions highlighted or a no match message

Parameters:
  • failure (Proc) -- a proc that processes the "no match" indication
  • success (Proc) -- a proc that processes the matched portion of the string
  • string (String) -- the string to be tested against the pattern
def show_match(
  string,
  success: -> s { Term::ANSIColor.green { s } },
  failure: -> s { Term::ANSIColor.red { s } }
)
  string =~ self ? "#{$`}#{success.($&)}#{$'}" : failure.("no match")
end