Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

RegEx for Comparing Two Strings with Partial Match

Qiu
21 - Polaris
21 - Polaris

I have two strings (A and B) and uncertain lenght sub-string are concated by "," and I want to compare these two strings to see if any sub-string is matching between Strings A and B. Below is sample data for input and desired output.
Can someone help me with a RegEx for this purpose? Thank you very much.

ABAnswer
1,2,3,42,3,5Y
1,2,3,45,6,7N
1,2,32,5,7Y
2 REPLIES 2
gawa
16 - Nebula
16 - Nebula

@Qiu Regex capturing and backreference will help in this case.

(1) To make Regex simpler, create concatenated string for this purpose. Tip here is to enclose all numbers by ",". (See field 'ConcatString')

(2) Use Regex_Match with following condition:  \1 means the same pattern as captured by (\d+) 

REGEX_Match([ConcatString], ".*\,(\d+)\,.*_.*\,\1\,.*")

image.png

Qiu
21 - Polaris
21 - Polaris

@gawa 
This is nice. I was expecting you to answer my question. 😁
Thank you very much.

Labels
Top Solution Authors