I have to extract -(4)- from a log and have to use regex.
my code is
regex /(?!-)\d{1}+(?=-)/
and input is
ASA-5510-6 : %ASA-4-106023: Deny udp src INTERNET:TEJ-BHARTI-ILL-2Mbps-
But with this regex it is also extracting similar other pattern (-5510-). I just want this(4) specfic four to be extracted.
and the whole log is
2011-12-01T00:02:04.382593+05:18 Dec 01 2011 00:00:29 KOC-TEJ-AMEX-ASA-5510-6 : %ASA-4-106023: Deny udp src INTERNET:TEJ-BHARTI-ILL-2Mbps-ROUTER-LAN-IP/58653 dst TCS:VIS-SYSLOG-SERVER/514 by access-group "INTERNET_access_in" [0xc97c8100, 0x0]
Thanks
Just put the %ASA in the lookbehind. Also the
{1}is redundant, and the+matches more than one 4./(?<=%ASA-)4(?=-)/gIf you just want to match a 4./(?<=%ASA-)\d+(?=-)/gIf you want to match any group of digits.(I was unsure if you wanted to just match a four or anything where the 4 was in the input example)