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 Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

Regex for repeating characters

spaul30
6 - Meteoroid

I am trying to find regex for 2 types of situations:

1. where string has letters repeating 3 times in the beginning like aaatgre, rrryutu, yyyuiop,www-retdfdf etc

2. where string has letters repeating 3 times in the end like rtyuiii, tyrdyyy, iioottqqq etc.

 

Can someone help me in building the regex for these two scenarios. Thanks !

5 REPLIES 5
CharlieS
17 - Castor
17 - Castor

Here's a not-so-RegEx method for this:

20190329-RepeatingChars.png

 

 

 

 

 

 

 

 

 

 

 

 

The only difference is if the Tile tool sorts the values first (so the original sequence doesn't matter) or not. 

spaul30
6 - Meteoroid

yes this solves the problem. Also i am looking for repeating characters in the first 3 and last 3 characters in a string. I was able to get the first 3 characters using Substring function. How to extract the last 3 characters of the string?

CharlieS
17 - Castor
17 - Castor

I'm glad that worked.

 

To get the last 3 characters: use the same method you did on the first 3 but on a reversed string using this function first:  ReverseString(

spaul30
6 - Meteoroid

it worked! thanks a ton!

SGDpackard
5 - Atom

Here is a bit quicker solution using RegEx if you want to implement. I've parsed the text from the opening three characters and the ending three characters. \l is shorthand for undercase, so if the letters are all upper case, use \u, if they are combination of upper and lower, use \w an make sure the "case insensitive" box is checked in the configuration window.

 

Sean