【问题标题】:.net regex split.net 正则表达式拆分
【发布时间】:2018-01-19 12:37:34
【问题描述】:

我有一句像“$[inception]$ 是一部令人难以置信的电影”这样的句子。我想用分隔符“$[...]$”分割“盗梦空间”。我想知道真正能够做到这一点的正则表达式模式。

【问题讨论】:

  • 你尝试过哪些模式?
  • 你想要什么结果? the is an incredible moviethe inceptionis an incredible movie 或其他?如果你得到$[ 而不是]$ 会发生什么,反之亦然?
  • 我只想得到分隔符的“inception”
  • 在这里玩regexstorm.net/tester
  • 你的意思是这样? regex101.com/r/i0KKvM/1

标签: c# .net regex


【解决方案1】:

正则表达式模式:

\$\[(.*?)\]\$

示例 C# 代码:

Regex.Match("the $[inception]$ is an incredible movie", "\\$\\[(.*?)\\]\\$").Groups[1]

【讨论】:

    猜你喜欢
    • 2012-11-05
    • 1970-01-01
    • 2013-08-11
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多