Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Return all characters after a specific string

jkv0019
8 - Asteroid

Hello All,

 

I am trying to get the hang of RegEx, but am having some trouble. I want to extract the city name after a column of identical strings, but different cities afterwards. My end goal is to retrieve Allen, Las Vegas, and San Diego as results from each line.

 

Kids Summer Camp 2021 At Location Allen

Kids Summer Camp 2021 At Location Las Vegas

Kids Summer Camp 2021 At Location San Diego

6 REPLIES 6
atcodedog05
22 - Nova
22 - Nova

Hi @jkv0019 

 

You can use replace function remove before string.

 

Replace([Field1], "Kids Summer Camp 2021 At Location ", "")

 

Workflow:

atcodedog05_0-1625843420495.png

 

Hope this helps 🙂

JosephSerpis
17 - Castor
17 - Castor

You could just parse everything after the word location and a white space in Regex. (.*) will capture everything the word Location followed by a space.

 

Regex_09072021.JPG

JoaoLeiteV
10 - Fireball

Hello @jkv0019,

 

I wrote down some examples of how you can get that information. In addition to @atcodedog05  formula, you can also use Regex in many different methods:

  1. Parse method: By using the expression "Location\s(.*)" you'll be able to get everything that's after "Location ";
  2. Tokenize method: The same expression here with a split to columns will have the same results;
  3. Replace method: By using the expression ".*Location\s(.*)" you'll get the same results, but in this case the output will be in the same column, erasing your older data.

Also, if you want to test out your expressions, I always use Regexr. It's a very nice tool where you can input your text and check in real-time how the results are going to be.

apathetichell
19 - Altair

Does your search term change? Like sometimes you'll be looking for location and other times you'll be looking for something else? If so you'll need to use a non-regex method (no fun!) or use a regex in a batch macro/app search... ie both are doable but require some additional work.

jkv0019
8 - Asteroid

Thank you. This is exactly what I had in mind!

apathetichell
19 - Altair

How are your search terms coming in? user input or other file? Are you searching all of your rows or just one row for the term?

Labels