为此正则表达式提供有效的语句

时间:2013-07-06 06:25:28

标签: regex expression

https://pastee.org/sg4xy

我对正则表达式不太满意,希望有人可以给我一个有效的陈述,并解释它是如何工作的,并且可能指向一个好的网站来学习正则表达式。

2 个答案:

答案 0 :(得分: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

有用的网站

答案 1 :(得分: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}»