本文整理汇总了C#中TextDocument.ReplacePattern方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.ReplacePattern方法的具体用法?C# TextDocument.ReplacePattern怎么用?C# TextDocument.ReplacePattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextDocument
的用法示例。
在下文中一共展示了TextDocument.ReplacePattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubstituteAllStringMatches
internal static void SubstituteAllStringMatches(TextDocument textDocument, string patternString, string replacementString)
{
TextRanges dummy = null;
int lastCount = -1;
while (textDocument.ReplacePattern(patternString, replacementString, StandardFindOptions, ref dummy))
{
if (lastCount == dummy.Count)
{
break;
}
lastCount = dummy.Count;
}
}
示例2: SubstituteAllStringMatches
/// <summary>
/// Substitutes all occurrences in the specified text document of the specified pattern
/// string with the specified replacement string.
/// </summary>
/// <param name="textDocument">The text document.</param>
/// <param name="patternString">The pattern string.</param>
/// <param name="replacementString">The replacement string.</param>
internal static void SubstituteAllStringMatches(TextDocument textDocument, string patternString, string replacementString)
{
TextRanges dummy = null;
int lastCount = -1;
while (textDocument.ReplacePattern(patternString, replacementString, StandardFindOptions, ref dummy))
{
// it is possible that the replacements aren't actually being done. In such a case,
// we can detect the situation by seeing if the count always remains the same, and
// if so exiting early.
if (lastCount == dummy.Count)
{
OutputWindowHelper.WarningWriteLine("Forced a break out of TextDocumentHelper's SubstituteAllStringMatches for a document.");
break;
}
lastCount = dummy.Count;
}
}
示例3: removeTrailingWhiteSpaces
public static void removeTrailingWhiteSpaces(TextDocument textDocument)
{
textDocument.ReplacePattern("[^\\S\\r\\n]+(?=\\r?$)", "", (int)vsFindOptions.vsFindOptionsRegularExpression);
}