Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
SOLVED

From Right to a specific character

Highlighted
7 - Meteor

Hi Everyone,

 

I'm having trouble figuring this out.

 

I have a data in this format.  Most of the code is delimited by a period but the last part by a colon. 

NW.SEAS.B154.1.LRC01:AI 1

NW.SEAS.B154.FHC01:AI_7

NW.AL3.256.LR:CTL TEMP

  

I need to take the portion that is to the right from the last period. For example:

From “NW.SEAS.B154.1.LRC01:AI 1”, I need “LRC01:AI 1”

From “NW.SEAS.B154.FHC01:AI_7”, I need “FHC01:AI_7”

From “NW.AL3.256.LR:CTL TEMP”, I need “LR:CTL TEMP”

 

Does anyone know of a tool or formula that will take the characters to the right of a specific delimiter?

Thank you,

Chris

 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Use this expression in a Formula tool where [Input] is the field containing the code values you provided as example.

 

Right([Input],FindString(ReverseString([Input]),"."))

 

This expression works based on the fact that you need the Right side of the string after the last period character. While we don't have a string function for the last character, we do have functions to reverse the characters of a string and then to find the first character. 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hi @ChrisB 

 

Using Regex Tool, with Parse Method, you can achieve what you want.

 

.*\.(.*:.*$)

 

ParseMethod.PNG

 

Cheers,

Highlighted
7 - Meteor

@CharlieS and @Thableaus 

Thank you for the quick replies.  Both of those are great options.

 

Thableaus - could you please explain the Regex syntax?  I am entirely new to it.  

 

 

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hey @ChrisB  no problem!

 

.*\.(.*:.*$)

 

Whatever is inside parenthesis is what you want to parse (isolate)

 

.*\. - This part means look for any character 0 or multiple times until you find the last period (\.)

The (.) character is a metacharacter, so you need to escape it to make the reference.

 

The parsing part:

(.*:.*$)

Bring me any character 0 or multiple times until you find a colon (:), then bring me any character after that 0 or multiple times until you find the end of the line ($)

 

There are some details of the RegEX sytnax that you need to get to know better to fully understand why the engine does some things that it does.

 

I recommend this website: https://www.rexegg.com/

 

Cheers,

Highlighted
Alteryx Partner
Alteryx Partner

@ChrisB Regex the most intimidating thing that should not be intimidating at all. @Thableaus sent over a great website for explaining what it is. If you want to do some real time testing, check out https://regex101.com/. Here you can paste your sample data in and play around with code and see how it reacts immediately.

Treyson Marks
Senior Analytics Engineer
PK Global
Labels