I have a list of strings such as
2007 ford falcon xr8 ripcurl bf mkii utility 5.4l v8 cyl 6 sp manual bionic
2004 nissan x-trail ti 4x4 t30 4d wagon 2.5l 4 cyl 5 sp manual twilight
2002 subaru liberty rx my03 4d sedan 2.5l 4 cyl 5 sp manual silver
I want to truncate the string at either the engine capacity (5.4l, 2.5l) or body type (4d wagon, 4d sedan), whichever comes first. So output should be:
2007 ford falcon xr8 ripcurl bf mkii utility
2004 nissan x-trail ti 4x4 t30
2002 subaru liberty rx my03
I figure I will create a list of words with .split(' '). However, my problem is how to stop at a x.xl or xd word where x could be any number. What sort of regex would pick this up?