I'm having trouble with regular expressions, can anyone please help.
I'm trying to convert a string into a regular expressions, but my expression is to broad and I need to narrow it down.
if I get a string "*.domain.co.za/*" I'm converting it to a regular expresson as such:
var expressionList = new List<Regex>();
var myString = "*.domain.co.za/*";
if (myString.IndexOf('*') >= 0)
expressionList.Add(new Regex(myString.Replace("*.", ".*\\.").Replace("/*", "/.*")));
the thing is this is far to broad how can I change the expression to validate to the following:
Must start with http or https followed by ://
Any number of char or numbers (no periods ".")
With these rules applied I think only the following will pass:
Is it possible to also allow http://domain.co.za
The following should not pass:
If it is possible please explain the expression.