-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 に答える