C#相当于Java Punctuation正则表达式 [英] C# equivalent of Java Punctuation regex

查看:81
本文介绍了C#相当于Java Punctuation正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在C#中找到相当于此正则表达式的等价物。

I'm looking to find the equivalent in C# for the equivalent of this regex.

Java:

public static final String expression = "[\\s\\p{Punct}]";

{Punct} 是保留字符类在Java但我不知道如何创建等效表达式,以便.net正则表达式引擎不会barf。

{Punct} is a reserved character class in Java but I'm not sure how to create the equivalent expression so that the .net regex engine doesn't barf.

推荐答案

使用此:

Regex regex = new Regex(@"[\s\p{P}]");

特别注意使用 @

这篇关于C#相当于Java Punctuation正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆