本文整理汇总了C#中Match.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Match.Copy方法的具体用法?C# Match.Copy怎么用?C# Match.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match.Copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Find
/// <summary>Searches for a match, beginning from a specified position.</summary>
/// <param name="text">The text to match against.</param>
/// <param name="startIndex">The starting position.</param>
/// <param name="anchored">Set to <c>true</c> to force matches to start from <paramref name="startIndex"/>.</param>
/// <returns>Result of the search.</returns>
internal Match Find(string text, int startIndex, bool anchored)
{
int length = text.Length;
if (Anchored) anchored = true;
Stack<Match> avail = new Stack<Match>();
Queue<Match> active = new Queue<Match>(nTransitions);
Match best = new Match(this, text, anchored);
Match start = new Match(this, text, anchored);
start.StateID = 0;
start.Position = startIndex;
if (!anchored) Scan(start);
do
{
Match current;
if (active.Count == 0 || active.Peek().Position > start.Position)
current = start;
else
current = active.Dequeue();
Transition[] trans = States[current.StateID];
for (int i = 0; i < trans.Length; i++)
{
if (Evaluate(current, trans[i].instruction, trans[i].target, true))
{
// don't duplicate work or run past the end of text
if (current.Position <= length && !active.Contains(current, sameFinal))
{
Match next;
if (avail.Count == 0)
next = new Match(this, text, anchored);
else
next = avail.Pop();
next.Copy(current);
active.Enqueue(next);
}
}
else if (Match.PosixPriority(current, best) > 0)
best.Copy(current);
Unevaluate(current);
}
if (current != start)
avail.Push(current);
else if (anchored || best.IsSuccess)
start.Position = length;
else
{
start.Position++;
Scan(start);
}
} while (active.Count > 0 || start.Position < length);
return best;
}