簡體   English   中英

preg_match_all 編譯失敗:字符類在偏移量處的范圍亂序

[英]preg_match_all Compilation failed: range out of order in character class at offset

我很難找到具有 preg_match_all 模式的特定對象。 我有一個文本。 但我只想找到一個特定的

就像我有一串文本

sadasdasd:{"website":["https://bitcoin.org/"]tatic/cloud/img/coinmarketcap_grey_1.svg?_=60ffd80');display:inline-block;background-position:center;background-repeat:no-repeat;background-size:contain;width:239px;height:41px;} .cqVqre.cmc-logo--size-large{width:263px;height:45px;}
/* sc-component-id: sc-2wt0ni-0 */

但是我只需要找到“網站”:[“ https://bitcoin.org/ ”]。 其中網站是動態數據。 比如網站可以是google“網站”:[“ https://google.com/ ”]

現在我有這樣的事情。 那只是返回大量網址。 我只需要具體的

    $parsePage = "sadasdasd:{"website":["https://bitcoin.org/"]tatic/cloud/img/coinmarketcap_grey_1.svg?_=60ffd80');display:inline-block;background-position:center;background-repeat:no-repeat;background-size:contain;width:239px;height:41px;} .cqVqre.cmc-logo--size-large{width:263px;height:45px;}
        /* sc-component-id: sc-2wt0ni-0 */";    
    $pattern = '/
     \"website":["          # [ character
                (?:         # non-capturing group
                    [^{}]   # anything that is not a { or }
                    |       # OR
                    (?R)    # recurses the entire pattern
                )*          # previous group zero or more times
           \"]              # ] character
    /x';
    preg_match_all($pattern, $parsePage, $matches);
    print_r($matches[0]);

嘗試 :

$pattern = '~"website":\["([^"]*)"~'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM