regex - Get multiple matches from text in curly braces -


i have sample file:

authoritative;  subnet x.x.x.x netmask x.x.x.x {     range x.x.x.x x.x.x.x;     deny unknown-clients;     default-lease-time 86400;     max-lease-time 86400;     option domain-name "bla";     option domain-name-servers x.x.x.x;     option broadcast-address x.x.x.x;     option subnet-mask x.x.x.x;     option routers x.x.x.x;      host host1 {         hardware ethernet 00:e1:4c:68:00:53;         fixed-address 1.1.1.1;     }      host host2 {         hardware ethernet 01:e2:4d:69:01:54;         fixed-address 2.2.2.2;     }      host host3 {         hardware ethernet 02:e3:4e:70:02:55;         fixed-address 3.3.3.3;     }      host host4 {         hardware ethernet 03:e4:4f:71:03:56;         fixed-address 4.4.4.4;     }      host host5 {         hardware ethernet 04:e5:5f:72:04:57;         fixed-address 5.5.5.5;     } } 

now i'm trying extract mac address , ip address parts within host x blocks. when use file structure (that includes newlines) doesn't match @ all... i'll address later on. i'm having hard time getting matches. have far: link myregex can see there, $1 , $2 contain last mac / ip address entries. how matches entries in sample file? i'm sure i'm missing essential...

thanks lot!

host.*?\{\s*hardware ethernet\s+(?:((?:[0-9a-fa-f]{2}:){5}[0-9a-fa-f]{2});\s*fixed-address\s+((?:\d{1,3}.){3}\d{1,3}));\s*\} 

tested here.


explanations

\s*\}\s*\} matching 1 closing brace many @ end of pattern.

[0-255] translates digits between 0 , 2, or 5. not want. it's easier use \d{1,3} here.

\sfixed-address need \s*fixed-address here since may have several spaces before fixed-address.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -