[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 48
  • Last Modified:

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.
0
newbieweb
Asked:
newbieweb
  • 2
1 Solution
 
aikimarkCommented:
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

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now