Skip to content

Commit

Permalink
Added: 添加数字匹配的正则
Browse files Browse the repository at this point in the history
  • Loading branch information
cdoco authored and ZiHang Gao committed Mar 27, 2017
1 parent e1d4134 commit 9c4f102
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 11 deletions.
124 changes: 113 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,44 @@

![Regex](images/regex.png)

## Table of Contents
## 目录

- [Email](#email)
- [Phone](#phone)
- [Domain-name](#domain-name)
- [邮箱](#邮箱)
- [电话](#电话)
- [域名](#域名)
- [IP](#ip)

## Email

`[email protected]`
- [数字正则](#数字正则)
- [整数](#整数)
- [正整数](#正整数)
- [负整数](#负整数)
- [非负整数](#非负整数)
- [非正整数](#非正整数)
- [浮点数](#浮点数)
- [正浮点数](#正浮点数)
- [负浮点数](#负浮点数)
- [非负浮点数](#非负浮点数)
- [非正浮点数](#非正浮点数)


## 邮箱

`[email protected]` 只允许英文字母、数字、下划线、英文句号、以及中划线组成

```regex
^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$
```

![email](images/email.png)

## Phone
`高子航[email protected]` 名称允许汉字、字母、数字,域名只允许英文域名

```regex
^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$
```

![email](images/email2.png)

## 电话

`13012345678`

Expand All @@ -29,7 +49,7 @@

![email](images/phone.png)

## Domain-name
## 域名

`https://google.com`

Expand All @@ -47,4 +67,86 @@
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))
```

![ip](images/ip.png)
![ip](images/ip.png)

## 数字正则

### 整数

```regex
^-?[1-9]\d*$
```

![num](images/num1.png)

### 正整数

```regex
^[1-9]\d*$
```

![num](images/num2.png)

### 负整数

```regex
^-[1-9]\d*$
```

![num](images/num3.png)

### 非负整数

```regex
^[1-9]\d*|0$
```

![num](images/num4.png)

### 非正整数

```regex
^-[1-9]\d*|0$
```

![num](images/num5.png)

### 浮点数

```regex
^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$
```

![num](images/num6.png)

### 正浮点数

```regex
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$
```

![num](images/num7.png)

### 负浮点数

```regex
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$
```

![num](images/num8.png)

### 非负浮点数

```regex
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$
```

![num](images/num9.png)

### 非正浮点数

```regex
^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$
```

![num](images/num10.png)
Binary file added images/email2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/num9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c4f102

Please sign in to comment.