我需要使用什么正则表达式将其转换为超链接? [英] What regex do I need to use to make this into a hyperlink ?

查看:78
本文介绍了我需要使用什么正则表达式将其转换为超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在我的文本输出文件中,我将在我的网页上显示

我有这个包括:

< blockquote class =post_quotes>
"位于:http://pggg-online.org/blog.htm"


有时:


"在这里找到www.example.org/james.htm"



将这些变为真实的最佳方式是什么?

工作链接例如:


< a href =''http://www.example.org/james.htm''target =''_ blank''> www.example.org/james.htm< /一个>



我想最好的方法是使用正则表达式吗?


当然我必须确保我不要如果已经给出了
http:// ,请加倍


感谢任何建议

解决方案

这是我到目前为止所拥有的:

展开 | 选择 | Wrap | 行号


为什么域名后面的斜线是可选的,但其后的其他东西不是? oO


@kovik


不确定你的意思,正则表达式会匹配示例。$

以及这些:


something.example.com

http://what.how的.com / wow.html?#

Hi

In my text output file that I will display on my webpage
I have this included:

"Located At: Http://pggg-online.org/blog.htm "

and sometimes :

"found here www.example.org/james.htm "


What is the best way to change these into real
working links eg:

<a href=''http://www.example.org/james.htm'' target=''_blank''>www.example.org/james.htm</a>

I guess that the best way is with a regular expression ?

Of course I have to make sure that I don''t double up the
http:// if it is already given

Thanks for any advice

解决方案

Here''s what I have so far:

Expand|Select|Wrap|Line Numbers


Why is the slash after the domain optional, but the rest of the stuff after it is not? o.O


@kovik
not sure what you mean, that regex will match example.com

and these too:

something.example.com
http://what.how.com/wow.html?#


这篇关于我需要使用什么正则表达式将其转换为超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆