---
title: "java正则提取图片链接"
author: "mjbb"
date: "2011-08-07T10:50:18Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2011-08-07T10:50:18Z"
id: 1141883
url: "https://mjbb.iteye.com/blog/1141883"
---

```
public static void main(String[] args) {
		  String str = "<input type='text' id='http://xxx.com/a.jpg' name='baijinshan' >";
//		  String regEx="(?<=id=')[\\S\\s]+(?=' name)";
		  String regEx="http://[([a-z0-9]|.|/|\\-)]+.[(jpg)|(bmp)|(gif)|(png)]";
		  Pattern p=Pattern.compile(regEx);
		  Matcher m=p.matcher(str);
		  boolean result=m.find();
		  System.out.println(m.group());
		}
```