Регулярное выражение между двумя закрывающими тегами

  • Автор темы lexavits1
  • 23
  • Обновлено
  • 16, May 2024
  • #1
Я хотел бы знать, какое будет регулярное выражение для и ? Или и ? Это берет первые закрывающие теги a и sup с последним закрывающим тегом div. Но мне нужны последние закрывающие теги a и sup вместе с последним закрывающим тегом div:
 <?php





$string = "<div><img src=\"/assets/images/copyChkboxOff.gif\" alt=\"Unchecked Copy Box\" class=\"copyBox hide-for-tablet\" data-bible-id=\"215010\"><a data-bible-id=\"215010\" data-type=\"tools\" href=\"/kjv/jdg/4/10/s_215010\" class=\"hide-for-tablet\">Jdg 4:10</a><span class=\"hide-for-tablet\"> - </span>And Barak <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H1301&t=KJV\">H1301</a></sup> called <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H2199&t=KJV\">H2199</a></sup> Zebulun <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H2074&t=KJV\">H2074</a></sup> and Naphtali <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H5321&t=KJV\">H5321</a></sup> to Kedesh; <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H6943&t=KJV\">H6943</a></sup> and he went up <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H5927&t=KJV\">H5927</a></sup> with ten <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H6235&t=KJV\">H6235</a></sup> thousand <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H505&t=KJV\">H505</a></sup> men <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H376&t=KJV\">H376</a></sup> at his feet: <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H7272&t=KJV\">H7272</a></sup> and Deborah <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H1683&t=KJV\">H1683</a></sup> went up <sup><a href=\"/lang/Lexicon/Lexicon.cfm?strongs=H5927&t=KJV\">H5927</a></sup> with him.</div>";

//$supdiv = "/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/";

//$supdiv = "/.*\(([^)]*)\)/";

//$supdiv = "/.*\(([^)]*)\)/";

$supdiv = "/<\/a><\/sup>(.*)<\/div>/";// /<\/sup>(.*)<\/div>/gm

preg_match_all($supdiv, $string, $lastWords, PREG_SET_ORDER);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL='https://lumtu.com/yti/dk55kdGRodHRwOi8vdzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25hbCh52']http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]">

<html xmlns="[URL='https://lumtu.com/yti/b0hh0bWxodHRwOi8vdzMub3JnLzE5OTkveGvkT']http://www.w3.org/1999/xhtml[/URL]">

<head>

<meta http-equiv="Content-Type" content="текст/html; кодировка = utf-8" />

<title>Untitled Document</title>

</head>

<body>

<?php

if(!empty($lastWords) || $lastWords !== NULL){

echo "lastWords: <pre>";

var_dump($lastWords);

echo "</pre><br /><br />\n";

}

?>

</body>

</html>
PHP:

lexavits1


Рег
10 Mar, 2015

Тем
1

Постов
1

Баллов
11
Тем
49554
Комментарии
57426
Опыт
552966

Интересно