html错误查找,如何在维护html标签/结构的同时查找/替换html中的文本

尝试有趣的事情。这样的作品。当我将此脚本附加到文本字段并要求他们翻译事物时, 我的朋友会喜欢它。我认为您可以做任何事情。毛皮。我检查了几次代码, 如果我想使用它, 它可以工作, 但是我对所有这些都不熟悉。我认为距开始学习php已经两三周了。

$html = ('

Dear so and so, after reviewing your application I. . .

More of the same...

sincerely,

Important Dude

');

$oldWords = array('important', 'sincerely');

$newWords = array('arrogant', 'ya sure');

// function for oldWords

function regex_oldWords_word_list(&$item1, $key)

{

$item1 = "/>([^<>]+)?\b$item1(tionally|istic|tion|ance|ence|less|ally|able|ness|ing|ity|ful|ant|est|ist|ic|al|ed|er|et|ly|y|s|d|'s|'d|'ve|'ll)?\b([^<>]+)?/";

}

// function for newWords

function format_newWords_results(&$item1, $key)

{

$item1 = ">$1 $item1$2$3";

}

// apply regex to oldWords

array_walk($oldWords, 'regex_oldWords_word_list');

// apply formatting to newWords

array_walk($newWords, 'format_newWords_results');

//HTML is not always as perfect as we want it

$poo = array('/ /', '/>([a-zA-Z\']+)/', '/’/', '/;([a-zA-Z\']+)/', '/"([a-zA-Z\']+)/', '/([a-zA-Z\']+)', '/\.\.+/', '/\. \.+/');

$unpoo = array(' ', '> $1', '\'', '; $1', '" $1', '$1

//and maybe things will go back to normal sort of

$repoo = array('/> /', '/; /', '/" /', '/ ');

$muck = array('> ', ';', '"','

//before

echo ($html);

//I don't know what was happening on the free host but I had to keep stripping slashes

//This is where the work is done anyway.

$html = stripslashes(preg_replace($repoo , $muck , (ucwords(preg_replace($oldWords , $newWords , (preg_replace($poo , $unpoo , (stripslashes(strtolower(stripslashes($html)))))))))));

//after

echo ('


' . $html);

//now if only there were a way to keep it out of the area between

// and here and tell it that english isn't math.

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值