RegEx to make a ReturnURL optional

Making a ReturnURL optional


I need to assert that the URL has one of the following:
  • a goto
  • a returnurl
  • no return url or goto

How do I change this RegEx

            string regEx = @"https?://(" + redirectWhitelist + ")/\\?(goto|returnurl)=https?://(" + redirectWhitelist + ")";

to permit making the following portion to be optional?
                                                                                                     \\?(goto|returnurl)=https?://(" + redirectWhitelist + ")";

Thanks.
newbiewebSr. Software EngineerAsked:
Who is Participating?
 
aikimarkConnect With a Mentor Commented:
string regEx = @"https?://(" + redirectWhitelist + ")/?((goto|returnurl)=https?://(" + redirectWhitelist + "))?";

Open in new window

0
 
newbiewebSr. Software EngineerAuthor Commented:
So, it was a matter of putting the whole text inside () and following with a ?
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks
0
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.

All Courses

From novice to tech pro — start learning today.