Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Regex getting special caracter

$
0
0
I have a string like:
 
string s1 = "dog().Cat(\"Happy\")";
 
I want to:
1) count the number of round brackets '(', I expect as result 2
2) get the text inside, I expect "\"Happy"\", which appear in console output as "Happy"
No idea for 1. I try the following for 2
 
string k = Regex.Match(s1,@"\((\w+)\)").Groups[1].Value;
 
But It fails in understanding the \" character
Any Idea?

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>