re = /(?<=см)\s*((?i:d=?\s*)?\d+(?:\.\d+)?\s*(?:см)?)/m
str = 'Салатник 600 мл h= 4.7 см 19.3см 19.3 см d 19.3 см d=19.3 см D=19.3 600 мл
Салатник 600 мл V= 4.7 л 19.3см 19.3 см d 19.3 см d=19.3 см D=19.3 600 мл
Салатни к 600 мл h= 4.7 19.3см 19.3 см d 19.3 см d=19.3 см D=19.3 600 мл
Салатник 600 мл h= 4.7 19.3см 19.3 см d 19.3 см d=19.3 см D=19.3 600 мл
Салатник 19.3см d=19.3 см 600 мл h= 4.7см 19.3 см d 19.3 см D=19.3 600 мл'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html