Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Remove http:// and https:// in a Website URL

jatienza
8 - Asteroid

Hi,

 

Need help in removing http:// and https:// in a website and add www. if it does have www. after removing http:// or https://, please samples below:

 

Raw Data:

http://www.sm.com

https://www.tracker.com

http://uncle.com

https://foryou.com

 

 

Output:

www.sm.com

www.tracker.com

www.uncle.com

www.foryou.com

 

 

Thanks,

Jaime

5 REPLIES 5
Felipe_Ribeir0
16 - Nebula

Hi @jatienza 

 

One way of doing this

 

REGEX_Replace([Field1], '(https{0,1}:\/\/)(www){0,1}\.{0,1}', 'www.')

 

Felipe_Ribeir0_0-1675375506501.png

 

binuacs
20 - Arcturus

@jatienza One way of doing this

 

binuacs_0-1675375607359.png

 

Luke_C
17 - Castor

Hi @jatienza 

 

Try something like this. The regex replace keeps everything after the slash. It also uses a contains function to determine if www needs to be added.

Luke_C_0-1675375632790.png

 

 

jatienza
8 - Asteroid

Thanks @Felipe_Ribeir0, it's working..

BS_THE_ANALYST
14 - Magnetar

@jatienza Nice problem! RegEx to the rescue 😂. Solution using an optional non-capturing group! I only learnt about them last week, very useful things.

BS_THE_ANALYST_0-1675378832926.png

To explain what it's doing: .*\/{2}(?:www\.)?

.*\/{2} means: any characters followed by exactly 2 forward slashes. Foward slash is a special character, you must escape it using: \/ (backslash)
(?:www\.)? means: an optional group. I.e. some strings may contain it, some strings may not. But if they do, please recognise it. i.e. optional non-capturing so that we can replace it. 

Everything together: .*\/{2}(?:www\.)? if you find this match in the string, replace it with: www.

Labels