Extracting URLs from a text document using Java + Regular Expressions

后端 未结 4 1559
醉话见心
醉话见心 2020-12-08 23:11

I\'m trying to create a regular expression to extract URLs from text documents using Java, but thus far I\'ve been unsuccessful. The two cases I\'m looking to capture are li

4条回答
  •  不思量自难忘°
    2020-12-08 23:27

    This link has very good URL RegExs (they are surprisingly hard to get right, by the way - thinh http/https; port #s, valid characters, GET strings, pound signs for anchor links, etc...)

    http://flanders.co.nz/2009/11/08/a-good-url-regular-expression-repost/

    Perl has CPAN libraries that contain cannedRegExes, including for URLs. Not sure about Java though :(

提交回复
热议问题