This file contains hidden or 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
def n5s(str) | |
first, num, last = str.match(/([a-zA-Z])(\d+)([a-zA-Z])/).captures | |
num = num.to_i | |
puts open("/usr/share/dict/words").grep(/\b#{first}[a-zA-Z]{#{num}}#{last}\b/) | |
end | |
> n5s("i18n") | |
institutionalization | |
intercrystallization | |
interdifferentiation |
This file contains hidden or 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
operator prefix ~ {} | |
@prefix func ~(pattern: String) -> NSRegularExpression! { | |
var error: NSError? | |
return NSRegularExpression.regularExpressionWithPattern( | |
pattern, | |
options: nil, | |
error: &error) | |
} |