-
-
Save havenwood/718c008d525f93f8d8826b8dcf3fda40 to your computer and use it in GitHub Desktop.
Rubular-like spike
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rubula | |
attr_accessor :test_string | |
def initialize test_string | |
@test_string = test_string | |
end | |
def match regexp | |
@test_string.match regexp | |
end | |
def match_results regexp | |
match_data = match regexp | |
puts "#{match_data.pre_match}\e[7m#{match_data[0]}\e[27m#{match_data.post_match}" | |
end | |
end | |
demo = Rubula.new 'cschneid_' | |
demo.match_results /s\w{3}/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment