Regex to extract data between dates

How do we build a regex to extract the ff (only extract capital letters data). data Thank you

Data string sample :

" 5/30/23/ , TEST DATE
6/30/23/ , HELLO WORLD "

output : TEST DATE , HELLO WORLD

I mean after dates

Hello

If you mean only extract capital letters after the date then try this pattern:

(?<=\d+/\d+/\d+/\s+,\s+)[A-Z\s]+

If you need just capital letters anywhere in a string try this pattern:
[A-Z]+

If you want to learn Regex - check out my Regex MegaPost for new users

Cheers

Steve

1 Like

Based on the data string sample, It looks like it is a comma-separated list. It may be easier to read as a CSV into a datatable and taking the column2 values. Or if you don’t want it as a datatable, it may be better to use a strings.split() function to split by newline, then by comma - this would make the 2nd/last value in the array for each line be your output string.

Regex can be extremely helpful, but it’s important to know when to use the different types of string extraction techniques instead. Each method of string extraction has pros/cons and when to use each will depend entirely on the input data structure

2 Likes

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