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.


sso.mydomain.com is okay, but the following is not
sso.mydomain.com.badURL.com


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

How?

Thanks
newbiewebSr. Software EngineerAsked:
Who is Participating?
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.

Rgonzo1971Commented:
Hi,

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

Open in new window

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

Open in new window

Regards
0

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;
0
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.
2
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

aikimarkCommented:
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.
0
louisfrCommented:
There could be an anchor. (/|\?|\#|$)
0
newbiewebSr. Software EngineerAuthor Commented:
thanks
0
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
Vulnerabilities

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.