Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Вопрос по написанию навороченнго регулярного выражения / 2 сообщений из 2, страница 1 из 1
06.12.2004, 18:31
    #32815183
vi
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
06.12.2004, 21:35
    #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
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Вопрос по написанию навороченнго регулярного выражения / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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