非中文标点符号正则表达式
时间: 2023-11-17 19:00:12 浏览: 50
非中文标点符号正则表达式可以使用Unicode字符集来实现。以下是一个示例正则表达式,可以匹配除了中文标点符号以外的所有标点符号:
```
[^\u4e00-\u9fa5\p{P}]+
```
其中,`\u4e00-\u9fa5`表示中文字符的Unicode范围,`\p{P}`表示所有标点符号的Unicode范围。`[^\u4e00-\u9fa5\p{P}]`表示除了中文字符和标点符号以外的所有字符。`+`表示匹配一个或多个这样的字符。
相关问题
中文标点符号正则表达式
中文标点符号的正则表达式可以使用以下格式:[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]
其中,每个符号都用竖线(|)分隔开,表示或的关系。可以根据需要添加或删除符号。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [【知识】正则表达式匹配中文标点符号](https://blog.csdn.net/meng_csdn_/article/details/125930354)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
java实现中文标点符号的正则表达式
要匹配中文标点符号,可以使用以下正则表达式:
```java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
String input = "你好,世界!";
String regex = "[\\pP\\pS]+";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
System.out.println("Match: " + matcher.group());
}
}
}
```
运行以上代码会输出:
```
Match: ,
Match: !
```
在上面的代码中,正则表达式 `[\\pP\\pS]+` 匹配了一个或多个中文标点符号。`\pP` 匹配任何标点符号,`\pS` 匹配任何符号字符。你可以根据需要修改正则表达式来匹配不同的中文标点符号或重新定义匹配规则。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)