---
title: "Java正则表达式笔记"
author: "sd7y"
date: "2014-05-22T11:32:17Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2014-05-22T11:32:17Z"
id: 2069571
url: "https://sd7y.iteye.com/blog/2069571"
---

```java
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
	String u = matcher.group(1);
}
Pattern pattern2 = Pattern.compile(regex, Pattern.DOTALL)//点(.)匹配所有(包括换行)
Matcher matches2 = pattern.matcher(content);
//也可使用以下方式
Pattern pattern3 = Pattern.compile("(?s)" + regex)//点(.)匹配所有(包括换行)
Matcher matches3 = pattern.matcher(content);

```