Blocking a period at a specific location using RegEx

Blocking a period at the end of a whitelisted URL?

I have a RegEx which is partly working to help verify a white listed list of domains, with '|' as delimiter, is working

              string regEx3 = @"https?://(" + whitelist + ")(.*)\\?(goto|returnurl)=https?://(" + whitelist + ")";

But I need to BLOCK a domain which uses my white listed domain as a sub-domain. is okay, but the following is not

I need to make the RegEx fail when it discovers a period after the white listed domain.


newbiewebSr. Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try by replacing
"(" + whitelist + ")"

Open in new window

"((" + whitelist + ")(?:[^\.]))"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
Have you considered alternative approaches?
eg. something like

String[] arWhitelist = whitelist.Split("|");  //get an array of the individual sites
foreach(string s in arWhitelist)
  if(String.Compare(s, sIsThisSiteOK, true) == 0)  //case independent comparison, 0 means the two strings match
    return true;
return false;
nociSoftware EngineerCommented:
Well there should be a / after domain names, or ? ... (or end of string)...
so a (/|\?|$)  at the end of the domain name should match this

so "((" + whitelist + ")(/|\?|$))"   should handle this case.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

From the examples you've shown us, there is not supposed to be any characters after your second whitelist. That is where the $ pattern comes in handy.  I think noci may be a bit more detailed than I would have been, so deserves points.
There could be an anchor. (/|\?|\#|$)
newbiewebSr. Software EngineerAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.