I have a string that looks like this:
msg": "log domain jl.lab.test.net server lab-jl-ppr-web"
I'm trying to extract "jl.lab.test.net" and JUST "lab-jl-ppr" from "lab-jl-ppr-web" using the following regular expression:
preg_match("/\"msg\"\: \"log domain\s([\w*\.]*) server ([\w*\.\-]*)/i",$line,$matches);
The second group currently matches the entire "lab-jl-ppr-web" string. I have been trying to specify the proper quantifier but so far I haven't gotten the right one. I've tried the following:
preg_match("/\"msg\"\: \"log domain\s([\w*\.]*) server ([\w*\.\-]*){3}/i",$line,$matches);
I'm continuing to play with it but if you have any tips, i'd appreciate it. Thanks.
Why not just
/..snip.. server ([\w*\.\-]*)-web/i
? Just keep -web
outside of the capture group.