Alteryx Designer Desktop Discussions

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

Regex function to return string between 2 charactes

AbdulBalogun
7 - Meteor

Im trying to create a regex function that gives me the string between 2 characters

 

I have the string below 

 

 

word1/word2/word3/word4/word5/word6/word7/word8_length_string.txt

 

 

and I'm trying to return everything after the 7th instance of "_" and before ".txt"

 

is there a regex function within the regex tool I can use to accomplish this?

 

 

 

8 REPLIES 8
binuacs
21 - Polaris
AbdulBalogun
7 - Meteor

Hey sorry, I should have put my actual the example below is the format in which my real string is in but when I used your regex code it didnt work

 

so the example below is the format in which my actual string is in 

 

00000000000000000000000000000000000000000000000000006666666666666 NACC-alteryxamp040320231500 [03/May/2024:16:04:45 +0000] 50.19.145.90 arn:aws:iam::449661041955:user/uploading-prod-app WWWWWWWWTTTYY REST.PUT.OBJECT uploading/NACC/AAAA/Inbound/filename_AAAA_uploading_files_string_20240503160217.txt.pgp "PUT /uploading/NACC/AAAA/Inbound/filename_AAAA_uploading_files_string_20240503160217.txt.pgp HTTP/1.1" 200 - - 121267 155 116 "-" "server3/1.9.57 Python/3.7.7 Linux/3.10.0-1160.95.1.el7.x86_64 newcore/1.12.86 Resource" - 73g2iMGiGECVq5L4EtEGpKURXQT/jbamYYrT02+aiQ9IPcHb0RpNPhldKk6ubbjYotEe5/QFN7I= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader NACC-alteryxamp040320231500.s3.amazonaws.com TLSv1.2 - -

 

I've highlighted my delimiters in pink and what I'm trying to pull in blue, so I want everything between the 7th instance of / and the first instance of txt.

 

shouldn't the code the provided work? I tried it with this as my string field and it didn't work, I saw it worked for the other example, not sure why this would be different

binuacs
21 - Polaris

@AbdulBalogun try 

REGEX_Replace([Input], '.*\/(.*)\.txt.*', '$1')

image.png

binuacs
21 - Polaris

@AbdulBalogun another regex

image.png

flying008
14 - Magnetar

Hi, @AbdulBalogun 

 

FYI.

REGEX_Replace([Txt], '^.?(?:[^\/]+?\/){7}([^\/]+?)(?=.txt).*', '$1')

 

录制_2024_05_08_07_56_16_567.gif

sureshmg
5 - Atom

Use RegEx and try this expression : (?:.*?[_/]){7}(.*?)\.txt

 

This should work.

 

AbdulBalogun
7 - Meteor

Thanks that worked!

 

similarly in the same code of 

 

00000000000000000000000000000000000000000000000000006666666666666 NACC-alteryxamp040320231500 [03/May/2024:16:04:45 +0000] 50.19.145.90 arn:aws:iam::449661041955:user/uploading-prod-app WWWWWWWWTTTYY REST.PUT.OBJECT uploading/NACC/AAAA/Inbound/filename_AAAA_uploading_files_string_20240503160217.txt.pgp "PUT /uploading/NACC/AAAA/Inbound/filename_AAAA_uploading_files_string_20240503160217.txt.pgp HTTP/1.1" 200 - - 121267 155 116 "-" "server3/1.9.57 Python/3.7.7 Linux/3.10.0-1160.95.1.el7.x86_64 newcore/1.12.86 Resource" - 73g2iMGiGECVq5L4EtEGpKURXQT/jbamYYrT02+aiQ9IPcHb0RpNPhldKk6ubbjYotEe5/QFN7I= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader NACC-alteryxamp040320231500.s3.amazonaws.com TLSv1.2 - -

 

do you know the regex function that would return that date time 03/May/2024:16:04:45 between the first [ and the ?

 

 

binuacs
21 - Polaris
Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels