public static void Main() { // TryMatch() can get a single match if (IsoDate.TryMatch("2021-02-03T01:23:45.678Z", out var isoDate)) { Console.WriteLine($"IsoDate: year={isoDate.Year} month={isoDate.Month} day={isoDate.Day}"); } // IsMatch() allows simple validity checks var testUsernames = new[] { "foo-bar", "foobar", "3foobar", "foo-bar-", "-foo-bar", "foo--bar" }; foreach (var username in testUsernames) { Console.WriteLine($"GithubUsername: {username}: {GithubUsername.IsMatch(username)}"); } // Matches() allows iterating through several matches var sourceText = "This is some example text showing URL matching, for https://example.org. " + "It will match with IPs http://192.0.2.1 or ftp://some.site.example.org and" + "also long ones https://user:[email protected]:4433/some/path?query=abc¶m=234."; foreach (var url in UrlRegex.Matches(sourceText)) { Console.WriteLine($"Found URL, scheme = {url.Scheme}, fullhost = {url.Fullhost}"); foreach (var path in url.Path) { Console.WriteLine(" " + path); } } }
public override XElement ToXML(bool internalPurpose = true) { XElement xml = new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + s_rootName); xml.Add( /* Personal Info: */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "description", Description.FixXML()), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "location", Location.FixXML()), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "webSite", WebSite.FixXML(), new XAttribute("redirect", RedirectToWebSite)), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "displayProfileInCommunity", DisplayProfileInCommunity), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "displayReputation", DisplayReputation), /* END Personal Info. */ /* Home Page Settings: */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeTopLeftPanel", HomeTopLeftPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeMidLeftPanel", HomeMiddleLeftPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeBotLeftPanel", HomeBottomLeftPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeTopRightPanel", HomeTopRightPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeMiddleRightPanel", HomeMiddleRightPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "homeBotRightPanel", HomeBottomRightPanel), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "displayQuickLink", DisplayQuickLink), /* END Home Page Settings. */ /* Browsing Options: */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "n_items", NItems), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "displayAvgRating", DisplayAvgRating), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "codeWrap", CodeWrap), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "tagsInFilters", TagsInFilters), /* END Browsing Options. */ /* Alerting System: */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "alerts", new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "newShareAlert", NewShareAlert), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "newCommentAlert", NewCommentAlert), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "alertEmail", AlertEmail), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "formatHtml", AlertFormatHtml), GetXElementForPeriodicity(internalPurpose, AlertType.ChannelsNews, AlertPeriod.Weekly), GetXElementForPeriodicity(internalPurpose, AlertType.CustomFromAdmin, AlertPeriod.ASAP), GetXElementForPeriodicity(internalPurpose, AlertType.BadgeNews, AlertPeriod.Weekly), GetXElementForPeriodicity(internalPurpose, AlertType.NewSnippetInGroup, AlertPeriod.ASAP), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "unsubChannels", Utilities.MergeIntoCommaSeparatedString(UnsubscribedChannels, true)) ), /* END Alerting System. */ /* Premium Preferences */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "premium", new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "maxPublishedItems", MaxPublishedItems), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "featuredUser", IsFeaturedUser)), /* END Premium Preferences */ /* Picture: */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "thumbUploadNum", ThumbUploadNum), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "gravatarEmail", GravatarEmail), /* END Picture. */ /* Third Parties Credentials */ new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "hasValidPsw", HasValidPsw), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "stackoverflowAccessToken", StackoverflowAccessToken.FixXML()), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "githubAccessToken", GithubAccessToken.FixXML()), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "githubUsername", GithubUsername.FixXML()), new XElement((internalPurpose ? "" : ConfigReader.S2CNS) + "twitterUsername", TwitterUsername.FixXML()) /* END Third Parties Credentials */ ); return(xml); }