Home  >  Article  >  Backend Development  >  Do you have any good methods to match URLs in paragraphs and convert them into clickable URLs?

Do you have any good methods to match URLs in paragraphs and convert them into clickable URLs?

WBOY
WBOYOriginal
2016-08-10 09:07:151239browse

Given a certain piece of text that contains a URL, how to extract the URL and replace it with clickable copy.

Example:

A copywriter:

<code>欢迎来到http://www.baidu.com/aaa/bbb,多谢指教!</code>

Copywriting after conversion:

<code>欢迎来到<a href='http://www.baidu.com/aaa/bbb'>http://www.baidu.com/aaa/bbb</a>,多谢指教!</code>

Do you have any good ideas

Reply content:

Given a certain piece of text that contains a URL, how to extract the URL and replace it with clickable copy.

Example:

A copywriter:

<code>欢迎来到http://www.baidu.com/aaa/bbb,多谢指教!</code>

Copywriting after conversion:

<code>欢迎来到<a href='http://www.baidu.com/aaa/bbb'>http://www.baidu.com/aaa/bbb</a>,多谢指教!</code>

Do you have any good ideas

Regular matching converted

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