Module: Word::Regexp
- Included in:
- Match
- Defined in:
- lib/word/regexp.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#word_regexp(wildcard = Word::WILDCARD, options = true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/word/regexp.rb', line 5 def word_regexp(wildcard = Word::WILDCARD, = true) wildcard = wildcard || Word::WILDCARD prefixed = /^(#{wildcard})/ suffixed = /(#{wildcard})$/ prefix = (wildcard and self =~ prefixed) ? "" : "\\b" suffix = (wildcard and self =~ suffixed) ? "" : "\\b" w = self.gsub(/#{prefixed}|#{suffixed}/, "") w = prefix + ::Regexp.escape(w) + suffix ::Regexp.new(w, ) end |