정규식 질문
본문
{"ret":0,"msg":"OK","channel_item":[{"streamprotocol":"HTTP","service_url":"http://1ab.xxxx.xx.co.kr/1tt-m/1tt-m_hd.m3u8?Expires=1611206278&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDovLzF0di5nc2Nkbi5rYnMuY28ua3IvMXR2LW0vMXR2LW1faGQubTN1OCIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYxMTIwNjI3OH19fV19&Signature=QUBneqUZpQ3xF6nsGzxTGJ7444x6DUcVfwNH~oPfblOs~WDfOquOftcHw2YkcFqXOmnpZp-nqhO0uqO0aGrhjy7j4PWgoyghXPlG3IdRtUA45bNqFev5XHi5~mwuub3UxKIS87-scDAVCM057T8RSFXvE4c2pVQlKnVwwWWthP9lknz9~foTDcLxdPC4Bw5OVlSjKxf51PhfsRUN~DhtMMBBwqZ9oP4aUs5E0BrWUhXx7DVBi0i5TpZHPeFDInM-s6n8rCQ6nxOJMuaWxdMJMd343w816izkYoRoV7Hh8pBzH7uR8sfwgQEYFe1uxWfPHR2XH2lcK3ZFuf68wp3Vig__&Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA","nid":"51100000007190","screentype":"1tv","bitrate":"500Kbps","channel_code":"11"},
php 정규식표현 에서 http부분만 ( http://......Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA )
정규식표현으로 할려면 어떻케 해야하나요?
!-->
답변 2
<?php
$str = '{"ret":0,"msg":"OK","channel_item":[{"streamprotocol":"HTTP","service_url":"http://1ab.xxxx.xx.co.kr/1tt-m/1tt-m_hd.m3u8?Expires=1611206278&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDovLzF0di5nc2Nkbi5rYnMuY28ua3IvMXR2LW0vMXR2LW1faGQubTN1OCIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTYxMTIwNjI3OH19fV19&Signature=QUBneqUZpQ3xF6nsGzxTGJ7444x6DUcVfwNH~oPfblOs~WDfOquOftcHw2YkcFqXOmnpZp-nqhO0uqO0aGrhjy7j4PWgoyghXPlG3IdRtUA45bNqFev5XHi5~mwuub3UxKIS87-scDAVCM057T8RSFXvE4c2pVQlKnVwwWWthP9lknz9~foTDcLxdPC4Bw5OVlSjKxf51PhfsRUN~DhtMMBBwqZ9oP4aUs5E0BrWUhXx7DVBi0i5TpZHPeFDInM-s6n8rCQ6nxOJMuaWxdMJMd343w816izkYoRoV7Hh8pBzH7uR8sfwgQEYFe1uxWfPHR2XH2lcK3ZFuf68wp3Vig__&Key-Pair-Id=APKAICDSGT3Y7IXGJ3TA","nid":"51100000007190","screentype":"1tv","bitrate":"500Kbps","channel_code":"11"},';
preg_match('%(http[^"]+)%i', $str, $matches);
print_r($matches);
답변 감사합니다 .
답변을 작성하시기 전에 로그인 해주세요.