community
cancel
Showing results for 
Search instead for 
Did you mean: 

alteryx server Discussions

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

Regex for repeating characters

Highlighted
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 !

Alteryx Certified Partner
Alteryx Certified Partner

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. 

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?

Alteryx Certified Partner
Alteryx Certified Partner

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(

Meteoroid

it worked! thanks a ton!

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