Quote:
when regex.IsMatch(latitude) == true
it still says it is invalid
Because your input and regex do not match.
Your input format look weird:
Instead of
27⁰33,04.24'' S 28⁰50,24.18'' E
it should look like
27⁰33'04.24'' S 28⁰50'24.18'' E
or
27⁰33'04.24" S 28⁰50'24.18" E
and also
27⁰ S 28⁰ E
27⁰33' S 28⁰50' E
27⁰33'04" S 28⁰50'24" E
should be valid
In your regex, I don't see any place to match °, ', ", B or E
Your regex is actually matching
27.45, 28.50
You should start by listing all valid input formats, then build the regex.
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[
^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[
^]
Expresso Regular Expression Tool[
^]
RegExr: Learn, Build, & Test RegEx[
^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[
^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[
^]
This site also show the Regex in a nice graph but can't test what match the RegEx:
Regexper[
^]