public static AssemblyIdentity FromAssemblyName(string assemblyName) { Match match = new Regex("^(?<name>[^,]*)(, Version=(?<version>[^,]*))?(, Culture=(?<culture>[^,]*))?(, PublicKeyToken=(?<pkt>[^,]*))?(, ProcessorArchitecture=(?<pa>[^,]*))?(, Type=(?<type>[^,]*))?").Match(assemblyName); string name = match.Result("${name}"); string version = match.Result("${version}"); string publicKeyToken = match.Result("${pkt}"); string culture = match.Result("${culture}"); string processorArchitecture = match.Result("${pa}"); return new AssemblyIdentity(name, version, publicKeyToken, culture, processorArchitecture, match.Result("${type}")); }
public override void Search() { string langStr = TextMiningUtils.GetLanguageCode(mLanguage); mResultSet.Inner.Clear(); if (mCache == null || !mCache.GetFromCache("GoogleDefine", mLanguage, mQuery, mResultSetMaxSz, ref mTotalHits, ref mResultSet)) { int i = 0; string defHtml = WebUtils.GetWebPage(string.Format("http://www.google.com/search?defl={0}&q=define%3A{1}", langStr, HttpUtility.UrlEncode(mQuery))); // throws WebException Match defMatch = new Regex("<li>(?<def>[^<]*)(<br><a href=\"(?<href>[^\"]*))?", RegexOptions.Singleline).Match(defHtml); while (defMatch.Success) { string def = HttpUtility.HtmlDecode(defMatch.Result("${def}").Trim()); string href = defMatch.Result("${href}"); string url = null; Match matchUrl = new Regex("&q=(?<url>[^&]*)").Match(href); if (matchUrl.Success) { url = HttpUtility.UrlDecode(matchUrl.Result("${url}")); } mResultSet.Inner.Add(new SearchEngineResultItem(mQuery, def, url, ++i)); defMatch = defMatch.NextMatch(); } string lastUrl = null; for (int j = mResultSet.Count - 1; j >= 0; j--) { if (mResultSet[j].Url == null) { mResultSet[j].SetUrl(lastUrl); } else { lastUrl = mResultSet[j].Url; } } mTotalHits = mResultSet.Count; if (mCache != null) { mCache.PutIntoCache("GoogleDefine", mLanguage, mQuery, mTotalHits, mResultSet); } if (mResultSetMaxSz < mResultSet.Count) { mResultSet.Inner.RemoveRange(mResultSetMaxSz, mResultSet.Count - mResultSetMaxSz); } } }
protected virtual void ParseTable (string table) { int start = table.IndexOf ('}')+1; Match m = new Regex (regex_table, RegexOptions.Compiled).Match (table); ParseRows (table.Substring (start, table.Length-start-1), m.Result ("${ns}"), m.Result ("${tbl}")); }
protected override ObjectWithId Add(DataTransferObject dto) { LocalAddressDTO sdto = (LocalAddressDTO) dto; if ((sdto.Level == AddressLevel.Дом) || (sdto.Level == AddressLevel.MaxAddress)) { Match match = new Regex(@"^(?<from>\d+)-(?<to>\d+)$").Match(sdto.Name); if (match.get_Success()) { int num; int num2; if (!int.TryParse(match.Result("${from}"), ref num) || !int.TryParse(match.Result("${to}"), ref num2)) { throw new System.ApplicationException("Ошибка при преобразовании номера в целочисленный тип"); } sdto.Name = ((int) num).ToString(); sdto.NameTo = ((int) num2).ToString(); System.Collections.Generic.List<LocalAddress> list = this.ParentAddress.AddLocalAddressRange(sdto); Messages.ShowMessage("Для отображения всего списка обновите родительский адрес"); return list.get_Item(0); } } return this.ParentAddress.AddLocalAddress(sdto); }
private static List<int> ReadFeatureVectors(StreamReader reader) { string line; List<int> feature_vectors = new List<int>(); while ((line = reader.ReadLine()) != null) { if (!line.StartsWith("#")) { Match label_match = new Regex(@"^(?<label>[+-]?\d+([.]\d+)?)(\s|$)").Match(line); Debug.Assert(label_match.Success); int label = Convert.ToInt32(label_match.Result("${label}")); Match match = new Regex(@"(?<feature>\d+):(?<weight>[-]?[\d\.]+)").Match(line); List<int> features = new List<int>(); List<float> weights = new List<float>(); while (match.Success) { int feature = Convert.ToInt32(match.Result("${feature}")); float weight = Convert.ToSingle(match.Result("${weight}"), System.Globalization.CultureInfo.InvariantCulture); match = match.NextMatch(); features.Add(feature); weights.Add(weight); } int vec_id = SvmLightLib.NewFeatureVector(features.Count, features.ToArray(), weights.ToArray(), label); feature_vectors.Add(vec_id); } } return feature_vectors; }
private string ParseUserId() { Match match = new Regex(@"user/(?<userId>\d+)/state/com.google/broadcast").Match(FeedId); if (!match.Success) return null; return match.Result("${userId}"); }