【问题标题】:C# Regex.replace Pattern needed需要 C# Regex.replace 模式
【发布时间】:2012-03-28 15:03:29
【问题描述】:

通常我自己制作Regex 模式,但我无法弄清楚这个:
我需要一个Regex.Replace 将“'Number'/'Number'”替换为“'Number'von'Number'”。

例如:“2/5”应该变成“2von5”。

问题是我不能只将“/”替换为“von”,因为还需要其他“/”。

【问题讨论】:

    标签: c# regex replace


    【解决方案1】:

    您可以使用lookaround(?<=\d)/(?=\d) 替换为von

    另一种选择是将(\d)/(\d) 替换为$1von$2(尽管在1/2/3 上会失败)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多