且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Ruby 中提取字符串中的所有 url

更新时间:2023-02-23 18:19:03

一种不同的方法,与完美是善的敌人思想不同:

A different approach, from the perfect-is-the-enemy-of-the-good school of thought:

urls = content.split(/\s+/).find_all { |u| u =~ /^https?:/ }