Alteryx Designer Desktop Discussions

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

Regex Question

bryan_ram2613
8 - Asteroid

Hi Regex People,

 

I am fairly new to regex and I am working to understand it. I am working with the expression ^.*website.+\.com.* 

I am testing different strings against it to understand the expression but I cannot seem to fully grasp. Why would website.com not match that expression? 

 

An explanation of that expression would be greatly appreciated!

 

Thanks!

3 REPLIES 3
lmorrell
11 - Bolide

Hi @bryan_ram2613 

 

In this case, it's a sneaky 

.+

that has entered your expression. The '.' specifies any character except line breaks, whereas the '+' specifies one or more of the preceding character. 

 

So taking your expression and turning it into English we get "starting from the beginning (^), match EVERYTHING up until the word 'website' (.*website), then match ONE OR MORE of any character (.+), then match that the string contains '.com' (\.com), ending with 0 or more of EVERYTHING"

 

If your aim is to make the expression match "website.com" then you could use 

^.*website\.com.*$

 

Hope this helps! 

danilang
19 - Altair
19 - Altair

Hi @bryan_ram2613 

 

Adding to @lmorrell excellent explanation, if you need to match string like websiteABC.com as well as website.com, change the ".+" (one or more) to ".*" (zero or more) so your final expression becomes

 

^.*website.*\.com.* 

 

Dan

bryan_ram2613
8 - Asteroid

@lmorrell  & @danilang Thank you helping me with this. Do either of you have a good resource for learning more or is it something you have to keep using?

Labels