Method: Translatomatic::Text#substrings

Defined in:
lib/translatomatic/text.rb

#substrings(regex) ⇒ Array<Translatomatic::Text] List of substrings

Find all substrings matching the given regex



104
105
106
107
108
109
# File 'lib/translatomatic/text.rb', line 104

def substrings(regex)
  matches = matches(@value, regex)
  strings = matches.collect { |i| match_to_substring(i) }.compact
  # return [self] if there's only one substring and it's equal to self
  strings.length == 1 && strings[0].eql?(self) ? [self] : strings
end