本文整理汇总了C#中System.Text.RegularExpressions.Regex.Matches方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.RegularExpressions.Regex.Matches方法的具体用法?C# System.Text.RegularExpressions.Regex.Matches怎么用?C# System.Text.RegularExpressions.Regex.Matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了System.Text.RegularExpressions.Regex.Matches方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitDigit
private string SplitDigit(string algorithm)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\b\d*([.]?\d*)?\b");
var temp = regex.Matches(algorithm);
int vIndex = 1;
string v = "var";
for (int i = 0; i < temp.Count; i++)
{
if (string.IsNullOrEmpty(temp[i].Value))
continue;
while (true)
{
v = "var" + vIndex.ToString();
var t = Variable.Keys.Where(p => p.Contains(v)).FirstOrDefault();
if (t == null)
break;
vIndex++;
}
var r = new System.Text.RegularExpressions.Regex(@"\b"+temp[i][email protected]"\b");
algorithm = r.Replace(algorithm, v, 1, temp[i].Index);
Variable.Add(v, double.Parse(temp[i].Value, new System.Globalization.CultureInfo("en-US")));
}
return "(" + algorithm + ")";
}
示例2: Run
/// <summary>
/// このクラスでの実行すること。
/// </summary>
/// <param name="runChildren"></param>
public override void Run(bool runChildren)
{
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"(\w*)\(([^)]*)\)");
List<string> list = new List<string>();
foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
{
if (string.IsNullOrEmpty(FunctionName))
{
list.Add(item.Groups[0].Value);
}
else
{
if (item.Groups[1].Value == FunctionName)
{
if (parameterOrder > -1)
{
var para = item.Value.Replace(FunctionName+"(","").Replace(")","").Split(',').ElementAtOrDefault(parameterOrder);
list.Add(para.Trim().Trim(new char[]{'\''}));
}
else
{
list.Add(item.Groups[2].Value);
}
}
}
}
this.RunChildrenForArray(runChildren, list);
}
示例3: Create
public override void Create(CommandParser Parser)
{
Parser.AddCommand(
Sequence(
RequiredRank(500),
KeyWord("KICK"),
Or(
Object("PLAYER", new ConnectedPlayersObjectSource(), ObjectMatcherSettings.None),
SingleWord("MASK"))))
.Manual("Makes bad people go away.")
.ProceduralRule((match, actor) =>
{
if (match.ContainsKey("PLAYER"))
KickPlayer(match["PLAYER"] as Actor, actor);
else
{
var mask = match["MASK"].ToString();
var maskRegex = new System.Text.RegularExpressions.Regex(ProscriptionList.ConvertGlobToRegex(mask), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//Iterate over local copy because kicking modifies ConnectedClients.
foreach (var client in new List<Client>(Clients.ConnectedClients))
{
var netClient = client as NetworkClient;
if (netClient != null && netClient.IsLoggedOn && maskRegex.Matches(netClient.IPString).Count > 0)
{
Core.MarkLocaleForUpdate(client.Player);
KickPlayer(client.Player, actor);
}
}
}
return PerformResult.Continue;
});
}
示例4: S
static void S()
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^(?>(0[12])*(?=02e))");
System.Text.RegularExpressions.MatchCollection matches = regex.Matches("01020102e");
Console.WriteLine();
int matchCount = 0;
foreach (System.Text.RegularExpressions.Match match in matches)
{
matchCount++;
Console.WriteLine("Match " + matchCount + ": " + (match.Value == null ? "NULL" : match.Value));
System.Text.RegularExpressions.GroupCollection groups = match.Groups;
int groupCount = -1;
foreach (System.Text.RegularExpressions.Group group in groups)
{
groupCount++;
Console.WriteLine("\tGroup " + groupCount + ": " + (group.Value == null ? "NULL" : group.Value));
System.Text.RegularExpressions.CaptureCollection captures = group.Captures;
int capCount = 0;
foreach (System.Text.RegularExpressions.Capture capture in captures)
{
capCount++;
Console.WriteLine("\t\tCapture " + capCount + ": " + (capture.Value == null ? "NULL" : capture.Value));
}
}
}
}
示例5: Refresh
public static void Refresh()
{
_port = 0;
_portSet = false;
_instances.Clear();
ManagementClass mgmtClass = new ManagementClass("Win32_Process");
foreach (ManagementObject process in mgmtClass.GetInstances())
{
string processName = process["Name"].ToString().ToLower();
if (processName == "msmdsrv.exe")
{
// get the process pid
System.UInt32 pid = (System.UInt32)process["ProcessId"];
var parentPid = int.Parse(process["ParentProcessId"].ToString());
var parentTitle = "";
if (parentPid > 0)
{
parentTitle = Process.GetProcessById(parentPid).MainWindowTitle;
if (parentTitle.Length == 0)
{
// for minimized windows we need to use some Win32 api calls to get the title
parentTitle = GetWindowTitle(parentPid);
}
}
// Get the command line - can be null if we don't have permissions
// but should have permission for PowerBI msmdsrv as it will have been
// launched by the current user.
string cmdLine = null;
if (process["CommandLine"] != null)
{
cmdLine = process["CommandLine"].ToString();
try
{
var rex = new System.Text.RegularExpressions.Regex("-s\\s\"(?<path>.*)\"");
var m = rex.Matches(cmdLine);
if (m.Count == 0) continue;
string msmdsrvPath = m[0].Groups["path"].Captures[0].Value;
var portFile = string.Format("{0}\\msmdsrv.port.txt", msmdsrvPath);
if (System.IO.File.Exists(portFile))
{
string sPort = System.IO.File.ReadAllText(portFile, Encoding.Unicode);
var port = int.Parse(sPort);
_port = port;
_portSet = true;
_instances.Add(new PowerBIInstance(parentTitle, port));
Log.Debug("{class} {method} PowerBI found on port: {port}", "PowerBIHelper", "Refresh", _port);
continue;
}
}
catch (Exception ex)
{
Log.Error("{class} {Method} {Error}", "PowerBIHelper", "Refresh", ex.Message);
}
}
}
}
}
示例6: Run
/// <summary>
/// このクラスでの実行すること。
/// </summary>
/// <param name="runChildren"></param>
public override void Run(bool runChildren)
{
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("<input [^>]*>");
System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w)*\s*=\s*"+"\"([^\"]*)\"");
var p = this.GetAncestorRawler().OfType<Page>();
if (p.Any() == false)
{
ReportManage.ErrReport(this, "上流にPageがありません");
return;
}
var page = p.First();
List<KeyValue> list = new List<KeyValue>();
foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
{
var dic = GetParameter(item.Value);
if (dic.ContainsKey("type") && dic["type"] == "hidden")
{
if (dic.ContainsKey("name") && dic.ContainsKey("value"))
{
page.AddParameter(dic["name"], dic["value"]);
list.Add(new KeyValue() { Key = dic["name"], Value = dic["value"] });
}
}
}
base.Run(runChildren);
}
示例7: Compare
/// <summary>
/// Compare two version strings
/// </summary>
/// <returns>1 if the first version is greater than the second version</returns>
public static int Compare(string Version1, string Version2)
{
if (Version1 == null && Version2 == null)
{
return 0;
}
if (Version1 != null && Version2 == null)
{
return 1;
}
if (Version1 == null && Version2 != null)
{
return -1;
}
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"([\d]+)");
System.Text.RegularExpressions.MatchCollection m1 = regex.Matches(Version1);
System.Text.RegularExpressions.MatchCollection m2 = regex.Matches(Version2);
int min = Math.Min(m1.Count, m2.Count);
for (int i = 0; i < min; i++)
{
if (Convert.ToInt32(m1[i].Value) > Convert.ToInt32(m2[i].Value))
{
return 1;
}
if (Convert.ToInt32(m1[i].Value) < Convert.ToInt32(m2[i].Value))
{
return -1;
}
}
int max = Math.Max(m1.Count, m2.Count);
for (int i = min; i < max; i++)
{
int v1 = (m1.Count < i ? Convert.ToInt32(m1[i].Value) : 0);
int v2 = (m2.Count < i ? Convert.ToInt32(m2[i].Value) : 0);
if (v1 > v2)
{
return 1;
}
if (v1 < v2)
{
return -1;
}
}
return 0;
}
示例8: Run
/// <summary>
/// このクラスでの実行すること。
/// </summary>
/// <param name="runChildren"></param>
public override void Run(bool runChildren)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern, regexOption);
StringBuilder sb = new StringBuilder(GetText());
foreach (System.Text.RegularExpressions.Match match in regex.Matches(GetText()))
{
sb.Replace(match.Value, string.Empty);
}
this.SetText(sb.ToString());
base.Run(runChildren);
}
示例9: GetValue
/// <summary>
/// 获取批量值
/// </summary>
/// <param name="str"></param>
/// <param name="s"></param>
/// <param name="e"></param>
/// <returns></returns>
public static System.Collections.Generic.List<string> GetValue(string str, string s, string e)
{
var rg = new System.Text.RegularExpressions.Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))");
var mc = rg.Matches(str);
var aStrings = new System.Collections.Generic.List<string>();
for (var i = 0; i < mc.Count; i++)
{
aStrings.Add(mc[i].Value);
}
return aStrings.Count <= 0 ? null : aStrings;
}
示例10: DigitsOnly_TextChanged
private void DigitsOnly_TextChanged(object sender, TextChangedEventArgs e)
{
var input = sender as TextBox;
var regex = new System.Text.RegularExpressions.Regex("[0-9]");
var value = String.Empty;
foreach (var item in regex.Matches(input.Text))
if (value.Length < 4)
value += item.ToString();
input.Text = value;
input.CaretIndex = 99;
}
示例11: Parse
public static HashSet<string> Parse()
{
var client = new System.Net.WebClient();
string pac = client.DownloadString(PACuri);
var RegIP = new System.Text.RegularExpressions.Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
var MatchResult = RegIP.Matches(pac);
var Hostlist = new HashSet<string>();
foreach (System.Text.RegularExpressions.Match m in MatchResult)
if (m.Value != "255.255.255.255" && m.Value != "127.0.0.1")
Hostlist.Add(m.Value);
return Hostlist;
}
示例12: GetParameter
private Dictionary<string, string> GetParameter(string input)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w*)\s*=\s*" + "\"([^\"]*)\"");
foreach (System.Text.RegularExpressions.Match item in r2.Matches(input))
{
string key = item.Groups[1].Value;
string val = item.Groups[2].Value;
dic.Add(key, val);
}
return dic;
}
示例13: GetPageCount
/// <summary>
/// 返回页数
/// </summary>
/// <param name="pdfPath">PDF文件地址</param>
private static int GetPageCount(string pdfPath)
{
byte[] buffer = System.IO.File.ReadAllBytes(pdfPath);
int length = buffer.Length;
if (buffer == null)
return -1;
if (buffer.Length <= 0)
return -1;
string pdfText = Encoding.Default.GetString(buffer);
System.Text.RegularExpressions.Regex rx1 = new System.Text.RegularExpressions.Regex(@"/Type\s*/Page[^s]");
System.Text.RegularExpressions.MatchCollection matches = rx1.Matches(pdfText);
return matches.Count;
}
示例14: EmailAddressPassesValidation
public bool EmailAddressPassesValidation(string EmailAddress)
{
using (new FunctionLogger(Log))
{
string Match = "^[a-zA-Z0-9_.+-][email protected][a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$";
System.Text.RegularExpressions.Regex EmailAddressRegEx = new System.Text.RegularExpressions.Regex(Match);
if (EmailAddressRegEx.Matches(EmailAddress).Count > 0)
return true;
return false;
}
}
示例15: WebPageLoadedSearchCalled
private void WebPageLoadedSearchCalled(object sender, WebPage.WebPageArguments args)
{
string htmlData = webpage.htmlData;
if (htmlData != null)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(_regexPattern);
results = regex.Matches(htmlData);
}
if(InfoReady != null)
{
InfoReady(this, new InfoReadyEventArgs("info ready"));
}
// webpage.WebPageLoaded -= WebPageLoadedSearchCalled;
}