-2

Hello all I am going through some old code and ran across a reg-ex, I cant figure out what it does, Can anyone shed some light on it.

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

it was in a replace string.replace statement.

4

2 回答 2

1

将您的正则表达式放入Regex101.com

底部是标题为的指南Your regular expression explained

于 2013-10-23T14:06:15.800 回答
0

根据 RegexBuddy,这是它的剂量:

Match either the regular expression below (attempting the next alternative only if this one fails) «<(.|\n)*?>»
   Match the character “&lt;” 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 “&gt;” 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 «}»

比赛是:

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

当 ... 是任何文本

于 2013-10-23T14:09:25.473 回答