re = /(zzdel\s+)(from\s+)([^\.]+)\.([^\s]+\s)([^\s]+)\n(INNER\s+)(JOIN\s+)([^\.]+)\.(T001\s+)(t0\s+)(on\s+)(t0\.mandt\s+)(=\s+)([^\.]+)\.(mandt\s+)/
str = 'from SPP01.AUFM t
\'\' zzdel
from LP101.AFRU afru
INNER JOIN SPP01.T001 t0 on t0.mandt = t.mandt
INNER JOIN SPP01.BSEG on x=y
from LP101.AFRU afru
INNER JOIN SPP01.T001 t0 on t0.mandt = t.mandt
INNER JOIN SPP01.T001 t0 on t0.mandt=t.mandt
INNER JOIN SPP01.T001 t0 on t0.mandt = t.mandt
(zzdel\\s+)
(from\\s+)([^\\.]+)\\.([^\\s]+\\s)([^\\s]+)
(INNER\\s+)(JOIN\\s+)([^\\.]+)\\.(T001\\s+)(t0\\s+)(on\\s+)(t0\\.mandt\\s+)(=\\s+)([^\\.]+)\\.(mandt\\s+)
(INNER\\s+)(JOIN\\s+)([^\\.]+)\\.([^\\.]+)(on\\s)([^\\.]+)(=)([^\\s]+)
\\1\\2\\.\\3\\4\\nINNER JOIN \\2\\.T001 t0 on t0\\.mandt =\\4\\.mandt'
# Print the match result
str.match(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