Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.
SOLVED

Regex expression for apha numeric column values

AbhishekkSinghh
7 - Meteor

Hello everyone, I am fairly new to regex, I have a data column that contains values like these 

"00P6_LUX_RPC
010T_ONT
010T_ONT_RPC

01P1_OMA_RPC
01P5_AUS"

 

I am able to write Regex for the values after the first underscore as its pretty straight forward using regex tool to replace these values with null. But the first 4 alpha numeric values I am not able to write a solution as there is no guarantee that the first 2 digits will be numbers or letter. 

 

Can anyone help.

 

Here is my current solution

 

 
 

alteryxqueryforregex.png

8 REPLIES 8
binuacs
21 - Polaris

@AbhishekkSinghh What is the expected result?

AbhishekkSinghh
7 - Meteor

communityquery_regex.pngHi Binuacs, the output I am expecting is the rows that contained values with the fixed expression to go blank. please look at the attached file for reference. 

 

Please also note that in the attached file, I am only able to remove one type of variable and since the first 4 values will contains alpha numeric values that can be at any destination, capturing all those values is proving to be a difficult task for me.

 

binuacs
21 - Polaris

@AbhishekkSinghh try the below regex

image.png

AbhishekkSinghh
7 - Meteor

Hey Binuacs,

 

Missed some values, here is an example of few that the expression was not able to handle.

 

"040T_002_RPC
AUT_RPC
BFW_RPC
BG50_001_RPC
BG52_001_RPC
BG54_001_RPC
BG56_001_RPC"

 

Was wondering if there would be a better way to handle these values, say create a formula, stating that if the end of the string value end with _RPC take that out or remove that value. but if that's not the best way to go about it then, how can we handle these values.

 

Also, forgive me for I didn't realise that the middle values could be numerical.

binuacs
21 - Polaris

@AbhishekkSinghh What about the below regex

image.png

AbhishekkSinghh
7 - Meteor

That didn't work either. As seen in my previous example, not all the values are words, after the first _ sometimes they can just be numbers.

 

Following is an emaple:

AUT_RPC
BFW_RPC
BG50_001_RPC

 

binuacs
21 - Polaris

@AbhishekkSinghh \w can read both word as well as numbers. Can you give me the expected result from the below input

 

00P6_LUX_RPC
010T_ONT
010T_ONT_RPC
01P1_OMA_RPC
01P5_AUS
040T_002_RPC
AUT_RPC
BFW_RPC
BG50_001_RPC
BG52_001_RPC
BG54_001_RPC
BG56_001_RPC

AbhishekkSinghh
7 - Meteor

Hi Binucas, that worked. Thanks! I was writing it without the \ backslash, and therefore was not able to see the empty rows. Thanks for everything, I have accepted your solution provided and will close this thread now. You have a good day! and hopefully I can be of some help to you someday as well.

Labels
Top Solution Authors