I have a huge logfile to parse through with PHP that looks for something like this (please note that variables that are variable will be labelled):
16:09:47.925 T#10648 PresenceManager: ࿚noticing[specialchar]$name[specialchar]0x8fac711e4bf14e62-d-s111.221.74.46:40022-r[IP]:48914-l192.168.1.2:48914f2812a403bdc6ade
I want to be able to look for this line that contains $name, then parse out the [IP] part, which is an IP. Please note there's two special char places which I have marked that cannot be shown in the post.
This is what I have:
if(preg_match('/' . $name . '*?-r(\d+\.\d+\.\d+\.\d+)/', $contents, $results))
However it doesn't seem to be finding the given ip like above D:
Pastebinny:: http://pastebin.com/YHh4fndP
$log = https://mega.co.nz/#!Scc11A6K!RXziJU_Ii43o1gcQetEfS7Kfzt-bY7VTJXljpCS7Gfc (username is sliceteam)
Thanks!
111.221.74.46string (i.e. the first set of 4 digits) or do you want the string after[IP]:?$namevariable? Can we assume that the string [IP] will only exist once on the line or that it's always the last instance?