Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Create Acronym from 1st uppercase letter at the start of each word

hellyars
13 - Pulsar

I need help with some regex.  I want to create abbreviations by capturing the first uppercase letter o each 2-N words.  I want to ignore all punctuation (Clean Tool?).  I want to ignore "and" and "&". 

 

I know how to target an uppercase letter at the start of each word e.g. ^[A-Z] or ^[[:upper:]].  I do not now how to adjust for the 2-N variability in the number of words.

 

Thanks.

 

Charlie Romea SierraCRS
Papa, Delta SierraPDS
Papa, Charlie AlphaPCA
Tango DownTD
Whiskey Tango FoxtrotWTF
Sierra November, Alpha Foxtrot UniformSNAFU
Sierra and Charlie NovemberSCN
Mike & India Kilo EchoMIKE
6 REPLIES 6
hellyars
13 - Pulsar

Don't do this ^([A-Z]+).  Do this ([A-Z]+).

 

I thought this would work.  It does, but doesn't.

AngelosPachis
16 - Nebula

Hi @hellyars ,

 

Does it have to be RegEx?

 

AngelosPachis_0-1611957487779.png

 

DavidP
17 - Castor
17 - Castor

Hi @hellyars 

 

Remember to uncheck the case insensitive checkbox.

 

DavidP_1-1611957709125.png

 

hellyars
13 - Pulsar

Preferably.  I ended up going this way myself.  It works, but regex lets you do it in one step.  But, thanks. 

AngelosPachis
16 - Nebula

Hi @DavidP ,

 

How would you translate this in plain-English?

 

They way I can read with my basic regex-skills is that you are looking to match one or more single uppercase characters and I know that $1 is a backreference, but how do all of them work together?

 

Hope you can enlighten me on that.

 

Thanks,

 

Angelos

DavidP
17 - Castor
17 - Castor

Hi @AngelosPachis 

 

For me, the key thing here is an understanding of the various options in the Regex tool, rather than the regex itself.

 

From the 4 output methods, let's ignore Match - we know that doesn't give us what we want.

 

Parse and Tokenize requires you to make a decision on how many columns to output.

 

For instance, (\u)+ in parse model will only output the 1st Capital and (\u)+ in Tokenize, you can choose how many columns, but each column will contain 1 Capital letter. You can make this last option work by picking a number bigger than the longest acronym and combining the result, but it's clumsy.

 

So now for Replace. 

 

If you happened to drag the Regex tool onto the canvas, set your regex to (\u)+ and unchecked the Case insensitive checkbox and did nothing else, leaving the default output mode as Replace with the Copy unmatched text to output, i.e. the default options except for case insensitive, you would have seen the original string without any of the Capital letters.

 

While this is not what you want as an output, it shows you that the regex has found everything that you wanted, but since the default in Replace mode replaces what was found with nothing, it actually removed it.

 

So all you have to do now is tell the tool to remove everything else and instead keep what it found in the 1st brackets. Hence the $1.

 

The best learning curve for me is to click all the buttons and see what happens!

 

 

Labels