Get all video qualities from a block of text using a regex

一世执手 提交于 2019-12-02 10:39:51

Remove the m and s modifiers from the preg_match_all() statement. These modifiers affect how the pattern matches the subject string, and are not always required:

  • m modifier changes the meaning of the line anchors (^ and $) from "match at the beginning/end of the string" to "match at the beginning/end of each line". If there are no newline characters in the subject string, or no occurrences of line anchors in the regex pattern, this modifier is useless.

  • s modifier changes the meaning of the dot meta-character (.) from "match everything except newline characters" to "match everything including newline characters". This allows you to treat the whole string as a single line.

See the PHP manual documentation on Pattern Modifiers for more information.


Your code should be:

preg_match_all("/(.*?)\/prog_index\.m3u8/i", $serviceurlget, $C);
print_r($C[1]);

Output:

Array
(
    [0] => 128
    [1] => 500
    [2] => 750
    [3] => 1000
    [4] => 1500
    [5] => 2500
)

Demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!