PHP/MySQL | [РЕШЕНО] регулярка preg_match_all + html на php
Тема закрыта by
Mr[G]Pro
Причина: РЕШЕНО
Причина: РЕШЕНО
Закрепленное сообщение:DELETED (14 мая 2022, в 18:49)
php
<?php $html = '<input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly=""> <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/d2d974a0y1/tgMetal_Family_2_TRAILER_mp4" readonly="">'; $regx = '~value="https://(.*?)/(.*?)/(.*?)"~is'; if (preg_match_all($regx, $html, $matches)) { foreach ($matches[2] AS $k => $id) { echo $id . ' - ' . $matches[3][$k] . '<br/>'; } } ?>
Не очень дружу с регулярными выражениями RegEx Источник парсинга: Curl html Нужно парсить несколько таких строк с html более 2х Через preg_match_all нужно получить отдельно значения всех найденных а также сохранить class="form-control upload-file-input" чтобы не парсило строку поиска на input tgMetal_Family_2_TRAILER_mp4 d2d974a0y1 Решено: (проблема кодировки была)
________
посл. ред. 14.05.2022 в 20:45; всего 3 раз(а); by Mr[G]Pro
html
<input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly=""> <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/d2d974a0y1/tgMetal_Family_2_TRAILER_mp4" readonly=""> php
preg_match_all('|value="[https]+://[anonfiles.com]+/(?<uid>.*?)/(?<name>.*?)"|is', html_entity_decode($response), $match) ________
посл. ред. 14.05.2022 в 20:45; всего 3 раз(а); by Mr[G]Pro
что тебе отсюда надо вытащить?
<input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly="">
<input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly="">
php
<?php $var = ' <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly=""> <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/d2d974a0y1/tgMetal_Family_2_TRAILER_mp4" readonly="">'; preg_match_all('|value="(.*?)"|is', $var, $match); for ($i = 0; $i <= count($var[1]); $i++) { echo $match[1][$i].'<br>'; }
d1nka , название файла и его индикатор отдельно
/(d2d974a0y1)/(tgMetal_Family_2_TRAILER_mp4) (в названии файла могут быть спец символы и пробелы)
________
посл. ред. 14.05.2022 в 17:02; всего 1 раз(а); by Mr[G]Pro
/(d2d974a0y1)/(tgMetal_Family_2_TRAILER_mp4) (в названии файла могут быть спец символы и пробелы)
________
посл. ред. 14.05.2022 в 17:02; всего 1 раз(а); by Mr[G]Pro
Mr[G]Pro (14.05.2022 в 17:01)
d1nka , название файла и его индикатор отдельно
/(d2d974a0y1)/(tgMetal_Family_2_TRAILER_mp4)
d1nka , название файла и его индикатор отдельно
/(d2d974a0y1)/(tgMetal_Family_2_TRAILER_mp4)
Вот отсюда ты как хочешь дальше чтобы вывело?
Mr[G]Pro (14.05.2022 в 17:01) d1nka , название файла и его индикатор отдельно /(d2d974a0y1)/(tgMetal_Family_2_TRAILER_mp4) (в названии файла могут быть спец символы и пробелы)
php
<?php $var = ' <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly=""> <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/d2d974a0y1/tgMetal_Family_2_TRAILER_mp4" readonly="">'; preg_match_all('|value="(.*?)"|is', $var, $match); for ($i = 0; $i <= count($var[1]); $i++) { $explode = explode('/', $match[1][$i]); echo 'индикатор '.$explode[3].' название файла '.$explode[4].'<br>'; }
DELETED
14 мая 2022, в 18:49
Delete
php
<?php $html = '<input class="form-control upload-file-input" type="text" value="https://anonfiles.com/79f4J7fey9/tgMetal-Family-Sezon-2-TRAILER_mp4" readonly=""> <input class="form-control upload-file-input" type="text" value="https://anonfiles.com/d2d974a0y1/tgMetal_Family_2_TRAILER_mp4" readonly="">'; $regx = '~value="https://(.*?)\/(.*?)\/(.*?)"~is'; if (preg_match_all($regx, $html, $matches)) { foreach ($matches[2] AS $k => $id) { echo $id . ' - ' . $matches[3][$k] . '<br/>'; } } ?>