网址URL提取

  1. public class RegexTests {
  2. public static void main(String[] args) {
  3. Pattern pattern = Pattern.compile("((https|http)?:\\/\\/)[a-zA-Z0-9|\\/|\\_|\\-|.|#|?|&|=|@]+");
  4. String input = "查看https://www.doU-y_in.com/dounine/japi。可查看http://pc.git_hub.com/dou-nine/jap_iAV23_ff#23?sdds&23=232@@@12。";
  5. Matcher matcher = pattern.matcher(input);
  6. while (matcher.find()) {
  7. System.out.println(matcher.group());
  8. }
  9. }
  10. }