php - Regular expressions / parsing dig output / extracting text from double quotes -
I need help finding some regular expressions. I am running the dig command and I have to use its output. I need to parse it and organize it systematically as an ARP php.
The dig makes something like this:
m0.ttw.mydomain.tel. TXT ".tkw" "in 60" "1" "20090624-183342" "some text here 1" m0.ttw.mydomain.tel. 60 in TXT ".kk" "1" "200 9 624-183341" "some text here 2"
I have to do this:
Array ([0] = & gt; Array ([0] = & gt; .kk [1] => 1 [2] => 20090624-183342 [3] = & gt; some text here 1) [ 1] = & gt; Arr .. ..)
I only need the contents of double quotation marks. I can do parse the output line dug by line I do, but I think it will be faster if I run regex patterns on it all ...
Thoughts?
it stops with a line
preg_match_all ( '/' ([^ "] +)" \ S * "([^"] +) "\ s *" ([^ "] +)" \ s * "([^"] + / ', $ Text, $ matches, PREG_SET_ORDER); Print_r ($ matches);
However, because how preg_match * functions work, the full match was included in index number 0 of each match group You can actually decide if you really wanted.
array_walk ($ matches, create_function ('& $ array', 'array_shift ($ array); return $ Array; '));
Comments
Post a Comment