can't seem to get right php regex quantifier -


i have string looks this:

msg": "log domain jl.lab.test.net server lab-jl-ppr-web" 

i'm trying extract "jl.lab.test.net" , "lab-jl-ppr" "lab-jl-ppr-web" using following regular expression:

 preg_match("/\"msg\"\: \"log domain\s([\w*\.]*) server ([\w*\.\-]*)/i",$line,$matches); 

the second group matches entire "lab-jl-ppr-web" string. have been trying specify proper quantifier far haven't gotten right one. i've tried following:

 preg_match("/\"msg\"\: \"log domain\s([\w*\.]*) server ([\w*\.\-]*){3}/i",$line,$matches); 

i'm continuing play if have tips, i'd appreciate it. thanks.

why not just

/..snip.. server ([\w*\.\-]*)-web/i 

? keep -web outside of capture group.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -