Need help with Regex

Pete_L

Active Member
Hi,
I am terrible with developing Regex patterns, and I'm hoping someone can help me. I need to develop a Regex pattern that will parse duplicate data from a string. The data is usually the same set of words 2X. For example one string might be "SAN FRANCISCO SAN FRANCISCO" and I want to return "SAN FRANCISCO". Another example might be "999 NW MAIN ST 999 NW MAIN ST" and I want to return "999 NW MAIN ST".

Before thinking about Regex, I was getting the length of the string, dividing by 2 and then using Left(), but that doesn't always work because I've found that the data can also include non-duplicated text (like "NEW YORK"), where unlike the previous examples it is not "NEW YORK NEW YORK".

Thanks in advance for your help.
 

Pete_L

Active Member
Thank you, RReed. I really appreciate your help. Your Regex pattern matches some of my string examples, but not others.

I had to move on with my project, so I chose a different route that is not using Regex. Since the strings contain the same data repeated twice, I am getting the LEN, dividing it by 2, and doing a Left() and a Right() using that LEN/2 value (and Trimming the result). Works perfectly for me, and I didn't have to use Regex (which I dread).
 
Top