MixedBeans
MixedBeans

Reputation: 159

how do I make the http and https optional using in RegEx

Ok. This should be a softball to fix but i am not a programmer and I am a bit under the gun so I can't really research and test. I have the following expression that works great:

https?:\/\/([1-9]\d{0,3})\.website\.com\/.*type=abc.adv=abc1234 

I have come to find out that sometimes our backend system will strip off the http:// of a URL like this

http://123.website.com/?&guid=blahblahblah&page=something&type=abc&adv=abc1234&site={siteID} I think my RegEx fails in these situations. I may be wrong. Can anyone confirm or maybe provide a way to make the "http(s)://" optional?

Thx!

Upvotes: 1

Views: 2814

Answers (2)

Desolator
Desolator

Reputation: 22759

http[s]*\:[\/]{2}[^.]+[.]website[.]com\/\?.+?&type=abc&adv=abc1234

Upvotes: 0

merlin2011
merlin2011

Reputation: 75555

Just group it and make it optional as a group.

(https?:\/\/)?([1-9]\d{0,3})\.website\.com\/.*type=abc.adv=abc1234 

Upvotes: 4

Related Questions