0

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)

Alan Moore
  • 71,299
  • 12
  • 93
  • 154
Aran Mulholland
  • 23,006
  • 28
  • 134
  • 225
  • Similar to http://stackoverflow.com/questions/2705990/c-equivalent-of-java-punctuation-regex – jjxtra Apr 30 '10 at 01:23

2 Answers2

1

found the answer, this is it

var m = Regex.Match(inputText.Substring(startPosition), @"(\p{P}){2,}");
Aran Mulholland
  • 23,006
  • 28
  • 134
  • 225
1

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
  • 278,830
  • 63
  • 599
  • 738