Home > Back-end >  Google Sheets Regexextract between specific points in string
Google Sheets Regexextract between specific points in string

Time:11-22

      CARD TRANSACTION            12NOV21 V DEBIT              007905AED       111.04            Card Ending with 8906            Majid Al Futtaim A89517641 ATM

Hi,

I have the above bank transaction string, and I am looking to extract the description which lies between 8906 and the unique transaction code immediately beginning with A i.e. desired output "Majid Al Futtaim".

I tried:

=regexextract(B2,"8906(. )A")

But the output I get is the spaces inherent and "Majid Al Futtaim A89517641", whereas I just want "Majid Al Futtaim" only.

Thanks in advance for your help.

CodePudding user response:

I would use this regex pattern:

Card Ending with \d \s ([A-Za-z] (?: [A-Za-z] \b)*)

Your updated sheets code:

=regexextract(B2, "Card Ending with \d \s ([A-Za-z] (?: [A-Za-z] \b)*)")

Here is a regex demo showing that the pattern is working.

CodePudding user response:

Given the sole string you've shared, this should work:

=REGEXEXTRACT(B2,"8906\s (. )\s \D*\d")

I've made some predictions about variation in pattern within this formula; but there is no way to control for something the scope of which I can't see in full.

CodePudding user response:

it should be:

=TRIM(REGEXEXTRACT(B2, "8906(. )A. "))
  • Related