-1

https://pastee.org/sg4xy

我对正则表达式不太了解,希望有人可以给我一个有效的声明,并解释它是如何工作的,也许可以将我指向一个学习正则表达式的好网站。

4

2 回答 2

0

您发布的正则表达式的解释(使用RegexBuddy创建):

^.syn ((([0-9]{1,3}\.){3}[0-9]{1,3})|([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+)) [0-9]{1,5} [0-9]{1,15} [0-9]{1,15}

Assert position at the beginning of the string «^»
Match any single character that is not a line break character «.»
Match the characters “syn ” literally «syn »
Match the regular expression below and capture its match into backreference number 1 «((([0-9]{1,3}\.){3}[0-9]{1,3})|([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+))»
   Match either the regular expression below (attempting the next alternative only if this one fails) «(([0-9]{1,3}\.){3}[0-9]{1,3})»
      Match the regular expression below and capture its match into backreference number 2 «(([0-9]{1,3}\.){3}[0-9]{1,3})»
         Match the regular expression below and capture its match into backreference number 3 «([0-9]{1,3}\.){3}»
            Exactly 3 times «{3}»
            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. «{3}»
            Match a single character in the range between “0” and “9” «[0-9]{1,3}»
               Between one and 3 times, as many times as possible, giving back as needed (greedy) «{1,3}»
            Match the character “.” literally «\.»
         Match a single character in the range between “0” and “9” «[0-9]{1,3}»
            Between one and 3 times, as many times as possible, giving back as needed (greedy) «{1,3}»
   Or match regular expression number 2 below (the entire group fails if this one fails to match) «([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+)»
      Match the regular expression below and capture its match into backreference number 4 «([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+)»
         Match a single character present in the list below «[a-zA-Z0-9_-]+»
            Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
            A character in the range between “a” and “z” «a-z»
            A character in the range between “A” and “Z” «A-Z»
            A character in the range between “0” and “9” «0-9»
            The character “_” «_»
            The character “-” «-»
         Match the character “.” literally «\.»
         Match a single character present in the list below «[a-zA-Z0-9_-]+»
            Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
            A character in the range between “a” and “z” «a-z»
            A character in the range between “A” and “Z” «A-Z»
            A character in the range between “0” and “9” «0-9»
            The character “_” «_»
            The character “-” «-»
         Match the character “.” literally «\.»
         Match a single character present in the list below «[a-zA-Z0-9_.-]+»
            Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
            A character in the range between “a” and “z” «a-z»
            A character in the range between “A” and “Z” «A-Z»
            A character in the range between “0” and “9” «0-9»
            The character “_” «_»
            The character “.” «.»
            The character “-” «-»
Match the character “ ” literally « »
Match a single character in the range between “0” and “9” «[0-9]{1,5}»
   Between one and 5 times, as many times as possible, giving back as needed (greedy) «{1,5}»
Match the character “ ” literally « »
Match a single character in the range between “0” and “9” «[0-9]{1,15}»
   Between one and 15 times, as many times as possible, giving back as needed (greedy) «{1,15}»
Match the character “ ” literally « »
Match a single character in the range between “0” and “9” «[0-9]{1,15}»
   Between one and 15 times, as many times as possible, giving back as needed (greedy) «{1,15}»
于 2013-07-06T11:06:43.523 回答
0

^.syn ((([0-9]{1,3}\.){3}[0-9]{1,3})|([a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_.-]+)) [0-9]{1,5} [0-9]{1,15} [0-9]{1,15}

一些匹配上述正则表达式的示例文本:

  • jsyn 467.317.98.0 7259 04124798576 90058
  • xsyn 3.5.0.545 952 7940 261348
  • Tsyn 9.47.-.u 3 12 5

有用的网站

于 2013-07-06T06:47:56.247 回答