Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
g

Test String

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r"(?P<node_down>(node\s[0-9]{1,2}\s(?i)changed to down))" test_str = ("3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-35.oit.umn.edu iswb01-38(id57) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 1594=\"kt: rtxn_split\")(tid=100694) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-38(id57)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-3.oit.umn.edu iswb01-39(id58) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 79573=\"kt: rtxn_split\")(tid=103364) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-39(id58)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-3.oit.umn.edu iswb01-39(id58) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 79573=\"kt: rtxn_split\")(tid=103364) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-39(id58)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 iswb01-22 /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 57389=\"kt: rtxn_split\")(tid=100517) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 iswb01-22 /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 57389=\"kt: rtxn_split\")(tid=100517) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-4.oit.umn.edu iswb01-33(id50) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 22700=\"kt: rtxn_split\")(tid=102764) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-33(id50)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-17.oit.umn.edu iswb01-21(id38) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 57611=\"kt: rtxn_split\")(tid=101420) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-21(id38)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-11.oit.umn.edu iswb01-10(id22) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 66612=\"kt: rtxn_split\")(tid=102391) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-10(id22)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-15.oit.umn.edu iswb01-14(id26) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 43481=\"kt: rtxn_split\")(tid=100397) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-14(id26)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-82.oit.umn.edu iswb01-3(id18) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 38185=\"kt: rtxn_split\")(tid=101529) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-3(id18)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-86.oit.umn.edu iswb01-7(id29) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 98280=\"kt: rtxn_split\")(tid=100697) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-7(id29)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-86.oit.umn.edu iswb01-7(id29) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 98280=\"kt: rtxn_split\")(tid=100697) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-7(id29)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-28.oit.umn.edu iswb01-29(id49) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 5976=\"kt: rtxn_split\")(tid=102030) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-29(id49)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-28.oit.umn.edu iswb01-29(id49) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 5976=\"kt: rtxn_split\")(tid=102030) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-29(id49)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-29.oit.umn.edu iswb01-31(id48) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 74876=\"kt: rtxn_split\")(tid=100348) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-31(id48)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-22.oit.umn.edu iswb01-24(id41) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 93203=\"kt: rtxn_split\")(tid=101594) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-24(id41)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-22.oit.umn.edu iswb01-24(id41) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 93203=\"kt: rtxn_split\")(tid=101594) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-24(id41)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-24.oit.umn.edu iswb01-30(id47) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 30963=\"kt: rtxn_split\")(tid=102227) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-30(id47)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-25.oit.umn.edu iswb01-32(id46) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 64148=\"kt: rtxn_split\")(tid=100516) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-32(id46)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-88.oit.umn.edu iswb01-43(id62) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 30042=\"kt: rtxn_split\")(tid=100521) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }\n" "clustername = iswb01 node_name_number_node_id = iswb01-43(id62)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-88.oit.umn.edu iswb01-43(id62) /boot/kernel.amd64/kernel: [gmp_info.c:1862](pid 30042=\"kt: rtxn_split\")(tid=100521) group change: <16,250707> [up: 54 nodes, down: 1 node, soft_failed: 1 drive] (node 31 changed to down, node 31 service smb changed to DOWN, node 31 service nfs changed to DOWN, node 31 service all_enabled_protocols changed to DOWN)\n" "clustername = iswb01 node_name_number_node_id = iswb01-43(id62)\n" "3/26/18\n" "4:04:57.000 PM \n" "2018-03-26T16:04:57-05:00 x-192-168-206-23.oit.umn.edu iswb01-26(id43) /boot/kernel.amd64/kernel: [gmp_info.c:1863](pid 28600=\"kt: rtxn_split\")(tid=100394) new group: <16,250707>: { 16:0-4,6-34,36-37, 17:0-35, 18:0-9,11-30,32-37, 19:0-1,3-11,13-33,35-38, 20:0-14,16-36, 21-22:0-35, 23:0-16,18-36, 24,26:0-35, 27:0-15,17-36, 28:0-35, 29:1-21,23-37, 32:0-20,22-36, 33:0-35, 34:0-6,8-9,11,13-30,32-39, 35:0-9,12-29,31-35,37-39, 36:0-11,13-30,32-37, 37:0-35, 38:0-13,15-36, 39-40:0-35, 41:0,2-36, 42:0-35, 43:0,2,4,6-18,20-39, 44-45:0-35, 46:0-10,12-36, 47:0-4,6-36, 48-51:0-35, 54:0-30,32-36, 55:0-14,16-36, 56:0-35, 57:0-32,35-37, 58:0-25,27-36, 59:0-14,16-36, 60:0-12,14-36, 61:0-24,26-36, 62:0-30,32-34,36, 63:0-34, 64:0-19,21-34,36, 65-66:0-34, 67:0-10,12-17,19-34,36-37, 68:0-34, 69:0-11,13-34,36, 70-74:0-34, down: 31, soft_failed: 62:23, smb: 16-24,26-29,32-51,54-74, nfs: 16-24,26-29,32-51,54-74, all_enabled_protocols: 16-24,26-29,32-51,54-74 }") matches = re.finditer(regex, test_str) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html