Regex to extract data between 3 - 8 digit number and 3 letter text(casplock text)

I wanted to extract the data between 3 - 8 digit number and 3 letter text(casplock text) using regex. Any idea would be much appreciated thank you.

Example data

06/29/20 B QM 02004946 MY HELLO WORLD XLS

OUTPUT : MY HELLO WORLD

0829/20 B QM 0948264 MY UI PATH  LMN

OUTPUT: MY UI PATH

0829/20 B QM 435 MY SAMPLE DATA   LMN

OUTPUT : MY SAMPLE DATA

I am assuming that “QM” is constant.

Split using Regex \d{3,} and keep the last item of the array. You will get below text (including last 3 letters)
MY HELLO WORLD XLS
MY UI PATH LMN
MY SAMPLE DATA LMN

Then remove last 3 characters and you have what you want

myString.Substring(myString.Trim.Length-3)

Here you can have a regex string for what you want, and the test cases tested:
(?<=\d{3}\s)([\w\s]*)(?=\s\w{3})
image

1 Like

Hi @Jelrey,

try this regex (?<=\d)\s[A-Z]+[A-Z]+[A-Z]+
Below is for your reference
image

if this solves your question then mark this as a solution.
Regards,
Aditya

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.