大梦123 2021-10-27 13:46:57

获取文本中的链接,并替换

        //获取连接的正则
		var pattern = /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/g;
		//获取文本框中的文本
        var content = $("#content").val();
		//将文本中匹配的内容替换
        var thinkContent = content.replace(pattern,"https://a.ynt2.cn/123456");

评论

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-21 01:38
浙ICP备14020137号-1 $Map of visitor$