This has been asked before here, but the answers are all PHP related. Is there a similar and working solution using C#? Like a specific test class or routine? I want to parse www.google.com or google.com or mywebsite.net etc... with or without prefixes. Thanks
Because C strings are array of characters. Arrays are simply pointers to the first element in the array, and when you compare two pointers using == it compares the memory address they point to, not the values that they point to.
The includes() method returns true if a string contains a specified string. Otherwise it returns false .
You can use contains(), indexOf() and lastIndexOf() method to check if one String contains another String in Java or not. If a String contains another String then it's known as a substring. The indexOf() method accepts a String and returns the starting position of the string if it exists, otherwise, it will return -1.
You can use string. indexOf('a') . If the char a is present in string : it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
https://msdn.microsoft.com/en-us/library/system.web.webpages.validator.regex(v=vs.111).aspx
you use the above mentioned class or use the below regex and check Regex matches with your url string
Regex UrlMatch = new Regex(@"(?i)(http(s)?:\/\/)?(\w{2,25}\.)+\w{3}([a-z0-9\-?=$-_.+!*()]+)(?i)", RegexOptions.Singleline);
Regex UrlMatchOnlyHttps = new Regex(@"(?i)(http(s)?:\/\/)(\w{2,25}\.)+\w{3}([a-z0-9\-?=$-_.+!*()]+)(?i)", RegexOptions.Singleline);
you can also use the above regexpattern to validate the url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With