---
title: "工作中会用到的正则表达式汇总"
author: "sunct"
date: "2016-07-20T13:31:08Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2016-07-20T12:58:25Z"
id: 2312366
url: "https://sunct.iteye.com/blog/2312366"
---

1、待匹配的文本：苹果,香蕉,葡萄,橘子,水蜜桃,

```
正则表达式：(\S)*?,
共找到 5 处匹配：
苹果,
香蕉,
葡萄,
橘子,
水蜜桃
```

 

2、待匹配的文本：select * from Employee where Fid=@Fid and DeptUid=@DeptUid

```
正则表达式：@\S+
共找到 2 处匹配：
@Fid
@DeptUid
```

 

 3、待匹配的文本：select * from Employee where Fid={Fid} and DeptUid={DeptUid}

```
正则表达式：\{\S+?\}
共找到 2 处匹配：
{Fid}
{DeptUid}
```

 

 4、待匹配的文本：苹果||香蕉&&葡萄&&橘子||水蜜桃&&

```
正则表达式：(\|\||&&)?\S+?(\|\||&&)
共找到 5 处匹配：
苹果||
香蕉&&
葡萄&&
橘子||
水蜜桃&&
```