以下数据给我一个去重正则表达式:1. ―Thanks for your tips. ―___________________ A. No, thanks. B. It' s my pleasure. C. Yes, please. [答案] B 2. ―Hi, Molly, are you free this afternoon? ―___________________ A. Yeah, no plans yet. B. Let' s see something special. C. That' s a good idea. [答案] A 3. ―Where have you been these days? ―___________________ A. Yes, I have. B. Actually, I have moved to the country. C. You are wanted on the telephone. [答案] B 4. ―Molly, look at this. The newspaper says we should sort trash. ―___________________ A. That would be great! B. No problem. C. It is obvious. [答案] A 5. ―I' ve got a bad cold today.
时间: 2024-03-04 10:49:07 浏览: 19
如果你想对这些数据进行去重,可以使用以下正则表达式:
```
pattern = r'―.+―'
```
这个正则表达式可以匹配所有以"―"开头和结尾的字符串,其中"."可以匹配任意字符,"+"表示匹配前面的字符一次或多次。使用这个正则表达式可以得到以下结果:
```
1. ―Thanks for your tips. ―
2. ―Hi, Molly, are you free this afternoon? ―
3. ―Where have you been these days? ―
4. ―Molly, look at this. The newspaper says we should sort trash. ―
5. ―I' ve got a bad cold today.
```
这些结果已经去重,可以直接使用。
相关问题
写一个正则表达式,校验a1_.b1_.c2_
以下是校验 `a1_.b1_.c2_` 的正则表达式:
```python
^[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+$
```
解释一下:
- `^` 表示字符串的开头
- `[a-zA-Z0-9_]+` 表示匹配一个或多个字母、数字或下划线
- `\.` 表示匹配一个点号
- `$` 表示字符串的结尾
因此,`^[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+$` 表示匹配由三个由字母、数字或下划线组成的部分,中间用点号连接的字符串。
javascript 正则表达式 转换 java 正则表达式_Javascript Regex到Java正则表达式
将 JavaScript 的正则表达式转换为 Java 的正则表达式,需要注意以下几点:
1. JavaScript 和 Java 的正则表达式语法略有不同,需要根据具体情况进行调整。
2. JavaScript 的正则表达式使用斜杠(/)作为分隔符,而 Java 的正则表达式使用双引号(")将正则表达式包含起来。
3. JavaScript 的正则表达式支持一些特殊的元字符和修饰符,需要将其转换为 Java 的等效元字符和修饰符。
下面是一个将 JavaScript 正则表达式转换为 Java 正则表达式的示例:
JavaScript 正则表达式:
```
var regex = /ab+c/i;
```
Java 正则表达式:
```
String regex = "ab+c";
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
```
在上面的示例中,我们将 JavaScript 的正则表达式 `/ab+c/i` 转换为 Java 的正则表达式 `"ab+c"`,并添加了 `Pattern.CASE_INSENSITIVE` 修饰符来指定不区分大小写匹配。