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

Alteryx designer Discussions

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

Regex Question

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

Alteryx Certified Partner

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! 

Nebula
Nebula

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

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