tags:

views:

123

answers:

2

I'm trying to match punctuations using regular expressions.

Do I have to specify every punctuation character I am searching for or is there is an escape sequence I can use?

I'm sitting here smiling to myself that the answers I might get will just be "Yes" or "No", please elaborate.... (that sentence should match the regular expression twice)

+1  A: 

found the answer, this is it

var m = Regex.Match(inputText.Substring(startPosition), @"(\p{P}){2,}");
Aran Mulholland
You don't need to specify all sub-categories, since the `\p{P}` category includes all of them
Thomas Levesque
cheers, updated
Aran Mulholland
A: 

Do i have to specify every punctuation character i am searching for or is there is an escape sequence i can use?

That would be a character class, not an escape sequence. You can use a character class defined by a Unicode category :

\p{P}

This expression matches characters in the category "All Punctuation". You can find a list of supported categories in the UnicodeCategory enumeration

Thomas Levesque