What’s the regular expression to check if a string starts with “mailto” or “ftp” or “joe” or…
Now I am using C# and code like this in a big if with many ors:
String.StartsWith("mailto:")
String.StartsWith("ftp")
It looks like a regex would be better for this. Or is there a C# way I am missing here?
You could use:
But to be honest,
StartsWithis perfectly fine to here. You could rewrite it as follows:You could also look at the
System.Uriclass if you are parsing URIs.