【问题标题】:How i can get the first match in regex and import this match in a string? [closed]我如何在正则表达式中获得第一个匹配项并将该匹配项导入字符串? [关闭]
【发布时间】:2016-11-12 18:06:29
【问题描述】:

例如使用正则表达式 del(.*?)del 获取 delcatdel 并将结果保存在字符串或文本中

word1word2delcatdelword3word4deldogdelword5

在我的文本(或字符串)中,我需要获取 delcatdel

使用升c

请大家帮帮我

【问题讨论】:

  • 使用Regex.Match
  • 关于正则表达式的问题有 155982 个。没有人帮你吗?
  • 没找到类似的答案,有点迷茫
  • I did not find a similar answer :) .........
  • 我在大约 8 秒内找到了类似的答案 - stackoverflow.com/a/18544928/3832970

标签: c# regex


【解决方案1】:
var regex = new Regex("del(.*?)del");
var match = regex.Match("word1word2delcatdelword3word4deldogdelword5");
string matched = match.Value;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 2014-06-26
    相关资源
    最近更新 更多