powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Вопрос по написанию навороченнго регулярного выражения
2 сообщений из 2, страница 1 из 1
Вопрос по написанию навороченнго регулярного выражения
    #32815183
vi
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Допустим у меня есть фрагмент HTML текста.

The code in many of the following examples is somewhat more explicit and less dense than <font color='red'> code <b> you are <i> likely </i> to find in actual </b> Web pages </font> . The intent here is to clarify the concepts, not to express optimal coding conciseness and style.

Который выглядит вот так

The code in many of the following examples is somewhat more explicit and less dense than code you are likely to find in actual Web pages. The intent here is to clarify the concepts, not to express optimal coding conciseness and style.

Мне нужно, замэтчить строку чистого! текста " dense than code you are likely to find in actual Web " игнорируя HTML тэги при поиске чтобы потом захайлатить этот текст, сделав желтый бэкграунд.

The code in many of the following examples is somewhat more explicit and less <span style="background:yellow"> dense than <font color='red'> code <b> you are <i> likely </i> to find in actual </b> Web </span> pages </font> . The intent here is to clarify the concepts, not to express optimal coding conciseness and style.

Может у кого есть готовый пример? Буду признателен.
...
Рейтинг: 0 / 0
Вопрос по написанию навороченнго регулярного выражения
    #32815385
Макс М.
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Можно так попробовать
Код: plaintext
1.
2.
3.
$reg = 'dense than code you are likely to find in actual Web';
$reg = preg_replace("~\s~", "\s*?(?:\<.+?\>){0,1}\s*?", $reg);
echo $str = preg_replace("~(".$reg.")~s", '<span style="background:yellow">\\1</span>', $str);
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Вопрос по написанию навороченнго регулярного выражения
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]