Regex HelperMatch With Group Names 方法
获取正则表达式的完整匹配结果和所有命名分组。
Definition
命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
元组:完整匹配值 + 命名分组字典(不含整体匹配组 "0")。 无匹配时返回 (string.Empty, 空字典)。
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static (string FullMatch, Dictionary<string, string> Groups) MatchWithGroupNames(
string input,
string pattern,
RegexOptions options = RegexOptions.None
)参数
- input String
- 要匹配的字符串。
- pattern String
- 包含命名分组的正则表达式模式,不能为 null 或空。
- options RegexOptions (Optional)
- 正则表达式选项(可选)。
返回值
ValueTupleString, DictionaryString, String元组:完整匹配值 + 命名分组字典(不含整体匹配组 "0")。 无匹配时返回 (string.Empty, 空字典)。
备注
与 MatchGroupsWithNames(String, String, RegexOptions) 一致,分组字典 不含整体匹配(组名 "0"),
整体匹配通过 FullMatch 单独返回。
异常
| ArgumentNullException | input 为 null。 |
| ArgumentException | pattern 为 null 或空。 |