正则表达式 - 文档

时间:2013-10-23 14:02:17

标签: c# regex

大家好,我正在阅读一些旧代码并遇到一个注册表,我无法弄清楚它的作用,任何人都可以对它有所了解。

<(.|\n)*?>|{(.|\n)*?} 

它位于替换string.replace语句中。

2 个答案:

答案 0 :(得分:1)

将正则表达式放入Regex101.com

底部是标题为Your regular expression explained

的指南

答案 1 :(得分:0)

据RegexBuddy说,这就是它的作用:

Match either the regular expression below (attempting the next alternative only if this one fails) «<(.|\n)*?>»
   Match the character “<” literally «<»
   Match the regular expression below and capture its match into backreference number 1 «(.|\n)*?»
      Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
      Note: You repeated the capturing group itself.  The group will capture only the last iteration.  Put a capturing group around the repeated group to capture all iterations. «*?»
      Match either the regular expression below (attempting the next alternative only if this one fails) «.»
         Match any single character that is not a line break character «.»
      Or match regular expression number 2 below (the entire group fails if this one fails to match) «\n»
         Match a line feed character «\n»
   Match the character “>” literally «>»
Or match regular expression number 2 below (the entire match attempt fails if this one fails to match) «{(.|\n)*?}»
   Match the character “{” literally «{»
   Match the regular expression below and capture its match into backreference number 2 «(.|\n)*?»
      Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
      Note: You repeated the capturing group itself.  The group will capture only the last iteration.  Put a capturing group around the repeated group to capture all iterations. «*?»
      Match either the regular expression below (attempting the next alternative only if this one fails) «.»
         Match any single character that is not a line break character «.»
      Or match regular expression number 2 below (the entire group fails if this one fails to match) «\n»
         Match a line feed character «\n»
   Match the character “}” literally «}»

匹配是:

<>
<...>
{}
{...}

当...是任何文本

相关问题