Regex HelperExtract Matches 方法
使用缓存编译的正则表达式提取所有匹配项。
Definition
命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
所有匹配项的字符串列表(新实例,可安全修改)。
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static List<string> ExtractMatches(
string input,
string pattern,
RegexOptions options = RegexOptions.None
)参数
- input String
- 要搜索的字符串。
- pattern String
- 正则表达式模式,不能为 null 或空。
- options RegexOptions (Optional)
- 正则表达式选项。
返回值
ListString所有匹配项的字符串列表(新实例,可安全修改)。
示例
C#
var numbers = RegexHelper.ExtractMatches("abc123def456", @"\d+");
// numbers = ["123", "456"]异常
| ArgumentNullException | input 为 null。 |
| ArgumentException | pattern 为 null 或空。 |