Last active
November 6, 2016 14:56
-
-
Save sanchojaf/1075f86a57419a5e64cc573fb241b080 to your computer and use it in GitHub Desktop.
Matching Keyword-Value Pair (ruby, regular expressions)
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
# Extracts the keyword and the value. The assumptions are that | |
# the keyword oor attribute is a single word, the value extends | |
# to the end of the line, and the equal sign may be surrounded | |
# by whitespace. | |
expression = /(\w+)\s*=\s*(.*?)$/ | |
sample_text = "color = blue" | |
sample_text =~ expression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment