Alteryx Designer Desktop Discussions

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

Check if two strings are separated by a single hyphen only

shobhit_gupta
7 - Meteor

I have a field in my data. I need to check by regex if two strings in that field are delimited/separated by a single hyphen(-) only. No other special characters should be there.

For example:

my field has string ASIAPAC-X722XXX. My regex should give "True" if data is in this format else "False" (since ASIAPAC and X722XXXare separated by a single hyphen only).

If string is ASIAPAC/-X722XXX or ASIAPAC--X722XXX or if any other special character/combination of special characters(even multiple hyphens) are delimiting the strings then regex match should give false.

 

I have tried using (\S*)-(\S.*) in my regex tool but it is not working as expected. It is working (giving True) only in cases when I replace "-" by any other special char in my string. In the below mentioned screenshot scenario, it should give false.

shobhit_gupta_1-1662116994043.png

My 2nd string (X722XXX) is always going to be a 7 digit alphanumeric string (if that helps).

 

3 REPLIES 3
messi007
15 - Aurora
15 - Aurora

@shobhit_gupta,

 

Please see below :

 

messi007_0-1662117744819.png

 

Regards,

binuacs
21 - Polaris

@shobhit_gupta 

 

IIF(REGEX_Match([Input], '\w+\-\w+'),'True','False')

 

shobhit_gupta
7 - Meteor

Awesome! This is what I was looking for. Thanks!

Labels
Top Solution Authors