Last active
          July 9, 2020 12:50 
        
      - 
      
- 
        Save jfversluis/560a387f3815711e342cbda04dcc3d1e to your computer and use it in GitHub Desktop. 
    Using Regex Named Groups in C#
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var azureDevOpsUrl = "https://dev.azure.com/jfversluis"; | |
| var resultUrl = ""; | |
| var azureDevOpsMatch = Regex.Match(azureDevOpsUrl, "(?<protocol>http[s]?://)(?<domainandpath>dev.azure.com/(?<accountname>[a-zA-Z]*)(.*))", RegexOptions.IgnoreCase); | |
| if (azureDevOpsMatch.Success) | |
| { | |
| resultUrl = $"{azureDevOpsMatch.Groups["protocol"]}{azureDevOpsMatch.Groups["accountname"]}@{azureDevOpsMatch.Groups["domainandpath"]}"; | |
| } | |
| Console.WriteLine(resultUrl); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment