Home  >  Article  >  Web Front-end  >  How to confirm whether the URL or email address in the text is genuine

How to confirm whether the URL or email address in the text is genuine

php中世界最好的语言
php中世界最好的语言Original
2018-04-26 17:43:172704browse

这次给大家带来怎样确认文本里url或邮件地址是否为真,确认文本里url或邮件地址为真的注意事项有哪些,下面就是实战案例,一起来看一下。

这段代码可以分析出文本里的所有超级链接,包含邮件、url、#链接等等,并分别输出为真实链接地址

$.fn.tweetify = function() {
 this.each(function() {
  $(this).html(
   $(this).html()
    .replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,'78a6ea1d6fdcbd6997af53c1a6338fb7$15db79b134e9f6b82c0b36e0489ee08ed')
    .replace(/(^|\s)#(\w+)/g,'$1abbe6e11680cd323af9eaa7665336e4f#$25db79b134e9f6b82c0b36e0489ee08ed')
    .replace(/(^|\s)@(\w+)/g,'$1ce51d33c093f304deec682724b588b87@$25db79b134e9f6b82c0b36e0489ee08ed')
  );
 });
 return $(this);
}

用法:

$("p").tweetify();

原始文本:

<p>@seanhood have you seen this http://icanhascheezburger.com/ #lol</p>

分析以后:

e388a4556c0f65e1904146cc1a846beea44a3222d8f1c5b6143e6cf0b799fb84@seanhood5db79b134e9f6b82c0b36e0489ee08ed have you seen this
320e43bf7f5f556f8b6cc4b542a4c38fhttp://icanhascheezburger.com/5db79b134e9f6b82c0b36e0489ee08ed
deaf16102efc20e850e623d100a3c45b#lol5db79b134e9f6b82c0b36e0489ee08ed94b3e26ee717c64999d7867364b1b4a3

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

jquery操作动画显示与隐藏效果效果

jQuery选项卡切换特效实现步骤

The above is the detailed content of How to confirm whether the URL or email address in the text is genuine. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn