Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Dima,</p> <p>Try this:</p> <pre><code>&lt;? preg_match('|content="\d+;url=(.*?)"|i', '&lt;META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.stackoverflow.com"&gt;', $res1); preg_match('|content="\d+;url=(.*?)"|i', '&lt;META CONTENT="5;URL=http://www.stackoverflow.com" HTTP-EQUIV="Refresh"&gt;', $res2); echo "&lt;pre&gt;"; var_dump($res1); var_dump($res2); echo "&lt;/pre&gt;"; ?&gt; </code></pre> <p>Output:</p> <pre><code>array(2) { [0]=&gt; string(44) "CONTENT="5;URL=http://www.stackoverflow.com"" [1]=&gt; string(28) "http://www.stackoverflow.com" } array(2) { [0]=&gt; string(44) "CONTENT="5;URL=http://www.stackoverflow.com"" [1]=&gt; string(28) "http://www.stackoverflow.com" } </code></pre> <p>Bear in mind that you'll have to deal with white spaces (inside content attribute, between tags, inside http-equiv attribute, etc.), such as:</p> <pre><code>&lt;META HTTP-EQUIV="Refresh" CONTENT=" 5 ; URL=http://www.stackoverflow.com "&gt; </code></pre> <p>The following code snippet handles that case:</p> <pre><code>&lt;? preg_match('|content="\s*\d+\s*;\s*url=(.*?)\s*"|i', '&lt;META HTTP-EQUIV="Refresh" CONTENT=" 5 ; URL=http://www.stackoverflow.com "&gt;', $res3); echo "&lt;pre&gt;"; var_dump($res3); echo "&lt;/pre&gt;"; ?&gt; </code></pre> <p>Output:</p> <pre><code>array(2) { [0]=&gt; string(48) "CONTENT=" 5 ; URL=http://www.stackoverflow.com "" [1]=&gt; string(28) "http://www.stackoverflow.com" } </code></pre> <p>Lastly, if that isn't enough, you can check for http-equiv="refresh" on each side of the content attribute (always takin into account the white spaces) like this:</p> <pre><code>&lt;? preg_match('|(?:http-equiv="refresh".*?)?content="\d+;url=(.*?)"(?:.*?http-equiv="refresh")?|i', '&lt;META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.stackoverflow.com"&gt;', $res4); preg_match('|(?:http-equiv="refresh".*?)?content="\d+;url=(.*?)"(?:.*?http-equiv="refresh")?|i', '&lt;META CONTENT="5;URL=http://www.stackoverflow.com" HTTP-EQUIV="Refresh"&gt;', $res5); echo "&lt;pre&gt;"; var_dump($res4); var_dump($res5); echo "&lt;/pre&gt;"; ?&gt; </code></pre> <p>Output:</p> <pre><code>array(2) { [0]=&gt; string(44) "CONTENT="5;URL=http://www.stackoverflow.com"" [1]=&gt; string(32) "http://www.stackoverflow.com" } array(2) { [0]=&gt; string(65) "CONTENT="5;URL=http://www.stackoverflow.com" HTTP-EQUIV="Refresh"" [1]=&gt; string(32) "http://www.stackoverflow.com" } </code></pre> <p>You could, using the same approach. add support for taking into account the parts.<br> Also, remember always to run regexes with i option, to enable case insensitive match.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload