In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

RegEx_Replace formula Find 8 consecutive numbers/digits and return that 8 digit value

taxguy33
8 - Asteroid

Hello,

 

I'm trying to grab the 8 digit number from the "Orig 1st Ref" column in my workflow via a REGEX_Replace formula, but I can't seem to get the syntax correctly.

 

If my "Orig 1st Ref" value is something like   "Random Word/12345678-001" then the below formula will return "Random Word/-001" when in reality I am just trying to get it to return 12345678 (the 8 digit number only) as the final result.

 

Please help me out - I'd really like to use the formula tool and not result to using the "Regex" tool is at all possible - I feel like there definitely is a way to do this, but I'm matching the 8 digits, not matching everything but the 8 digits which is my problem.

 

 

Current Regex_Replace formula:

if IsEmpty([Project #]) and [AtLeast8#s]>=1 then
REGEX_Replace([orig 1st Ref], "\b\d{8}\b","$1")
else [Project #]
endif

 

Thanks,

taxguy33

2 REPLIES 2
mbarone
16 - Nebula
16 - Nebula

This should work:

 

REGEX_Replace(
REGEX_Replace([text],'.+?(?=\b\d{8}\b)',''),
'(?<=\b\d{8}\b).*$','')

gabrielvilella
14 - Magnetar

Hi @taxguy33, maybe this one works for you: REGEX_Replace([Field1], '.+\/(\d{8})-\d+', '$1')

Labels
Top Solution Authors