Regex.InfiniteMatchTimeout 字段
定义
指定模式匹配操作不应超时。Specifies that a pattern-matching operation should not time out.
public: static initonly TimeSpan InfiniteMatchTimeout;
public static readonly TimeSpan InfiniteMatchTimeout;
staticval mutable InfiniteMatchTimeout : TimeSpan
Public Shared ReadOnly InfiniteMatchTimeout As TimeSpan
字段值
注解
Regex(String, RegexOptions, TimeSpan)类构造函数和多个静态匹配方法使用 InfiniteMatchTimeout 常数指示查找模式匹配项的尝试不会超时。The Regex(String, RegexOptions, TimeSpan) class constructor and a number of static matching methods use the InfiniteMatchTimeout constant to indicate that the attempt to find a pattern match should not time out.
警告
将正则表达式引擎的超时值设置为 InfiniteMatchTimeout 可能会导致依赖过多回溯的正则表达式似乎在处理与正则表达式模式几乎匹配的文本时停止响应。Setting the regular expression engine's time-out value to InfiniteMatchTimeout can cause regular expressions that rely on excessive backtracking to appear to stop responding when processing text that nearly matches the regular expression pattern. 如果禁用超时,则应确保正则表达式不依赖于过度回溯,并处理与正则表达式模式几乎匹配的文本。If you disable time-outs, you should ensure that your regular expression does not rely on excessive backtracking and that it handles text that nearly matches the regular expression pattern.
有关如何处理回溯的详细信息,请参阅 回溯。For more information about handling backtracking, see Backtracking.
InfiniteMatchTimeout可以将常量作为以下成员的参数值提供 matchTimeout :The InfiniteMatchTimeout constant can be supplied as the value of the matchTimeout argument of the following members:
RegexCompilationInfo.RegexCompilationInfo(String, RegexOptions, String, String, Boolean, TimeSpan)
Replace(String, String, MatchEvaluator, RegexOptions, TimeSpan)