re = /^([\w]+)\s(.*?)(?=\(|incl\.|[A-Z]$)(?:\(([a-zA-Z]+)-?(.*?)\))?(?:.*(incl.*))?([A-Z])$/m
str = 'Branded 16 ft Box Truck (Entrent - Avalen Owned) incl. New DSP Insurance PaymentP
Branded Extended Van (Entrent - Avalen Owned) incl. New DSP Insurance PaymentR
Branded Custom Van (Entrent - Avalen Owned) incl. New DSP Insurance PaymentR
Branded Custom Delivery Van (Entrent -Avalen Owned) incl. New DSP
Branded Extended Van (CeasePlan - Avalen Owned)R
Branded Extended Van (Entrent - Avalen Owned)R
Owned Van incl. New DSP Insurance PaymentP
Rental Van (Unbranded CSP)R
Owned 16ft Box TruckR
Branded 24ft Box Truck (Entrent - Leased)P
Leased Van incl. New Csp Insurance PaymentR'
# 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