Home > Backend Development > PHP Tutorial > 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
Release: 2016-08-10 09:07:15
Original
1299 people have browsed it

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>
Copy after login
Copy after login

Copywriting after conversion:

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

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>
Copy after login
Copy after login

Copywriting after conversion:

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

Do you have any good ideas

Regular matching converted

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template