---
title: "Java 正则截取两个标签之间字符串"
author: "mlxnle"
date: "2012-10-13T19:32:07Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2018-09-12T14:58:18Z"
id: 1697880
url: "https://mlxnle.iteye.com/blog/1697880"
---

Java 正则 , 截取两个标签之间字符串 ：

 

```
String testStr = "12315<Test>show me</text>";
Pattern p = Pattern.compile("<Text>(.*)</Text>");
Matcher m = p.matcher(testStr);
while(m.find()){
System.out.println(m.group(1));
}
```

```
如上, 控制台输出应为:show me.
```