I have a string like:
string str = "https://abce/MyTest";
I want to check if the particular string starts with https://
and ends with /MyTest
.
How can I acheive that?
This regular expression:
^https://.*/MyTest$
will do what you ask.
^
matches the beginning of the string.
https://
will match exactly that.
.*
will match any number of characters (the *
part) of any kind (the .
part). If you want to make sure there is at least one character in the middle, use .+
instead.
/MyTest
matches exactly that.
$
matches the end of the string.
To verify the match, use:
Regex.IsMatch(str, @"^https://.*/MyTest$");
More info at the MSDN Regex page.
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