I have data in a column in this format:
1 P01 - Product Name here - PAID IN FULL
2 P02 - Product2 Name here - PARTIALLY PAID 20
1 P03 - Product2 Name here
I've been trying to extract just the middle part, i.e. the code & product name, using regex. This bit P03 - Product2 Name here The dash between the code & name should be left as is.
I managed to remove the first bit, 1.... etc, but I can't seem to get rid of the last bit - PAID IN FULL etc. This last dash should also go.
Using Regexreplace
=ARRAYFORMULA(TRIM(REGEXREPLACE(A2:A3, "^(\d)\s", "")))
result: P01 - Product Name here - PAID IN FULL
Regexextract
=arrayformula(REGEXEXTRACT(A2:A3, "[^(\d)\s].*"))
result: P01 - Product Name here - PAID IN FULL
=arrayformula(REGEXEXTRACT(A2:A3, "[^(\d)\s+].*[^-A-Z$]"))
result: P01 - Product Name here - PAID IN
Extract & replace
=arrayformula(REGEXEXTRACT(A2:A4, "[^(\d)\s+].*[^-$]"))
result:
Same above formula edited a bit to remove ^ before - :
=arrayformula(REGEXEXTRACT(A2:A4, "[^(\d)\s+].***[-$]**"))
result: