---
title: "常用正则"
author: "ylsuccess"
date: "2010-08-10T11:04:15Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-08-10T11:04:15Z"
id: 733490
url: "https://ylsuccess.iteye.com/blog/733490"
---

```java


String url = "[a-za-z0-9][-a-za-z0-9]{0,62}(\\.[a-za-z0-9][-a-za-z0-9]{0,62}){0,1}(\\.[a-za-z]+)";

String ip = "(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])"

Pattern pattern = Pattern.compile();
Matcher matcher = pattern.matcher(tempValue); 
if(!matcher.matches())
{
    //不匹配
}


```