Home > Net >  C # how to use regular expressions to extract a string of Chinese characters in the ()
C # how to use regular expressions to extract a string of Chinese characters in the ()

Time:09-28

Actually I wanted to use a for loop to a string array of all the Chinese are extracted from the characters in parentheses to another array, of course, the most important is the problem that the title, please welcome the big show

CodePudding user response:

Want to use for regular balance

CodePudding user response:

([^ ()] +)

CodePudding user response:

 
String ch="fdsfdsa (FDS) DSFDS";
MatchesSection (ch, false);
Public static List MatchesSection (string ch, bool isInclude)
{
String strRegex=isInclude? @ (\ "(\ [^ \] *)" : @ "(? <=\ [^ \] () + ";//
MatchCollection Matches=Regex Matches (ch, strRegex, RegexOptions IgnoreCase);
List STR=new List (a);
Foreach (Match NextMatch in Matches)
{
STR. The Add (NextMatch. Value);
}

return str;
}

https://blog.csdn.net/u013010499/article/details/103250879
  •  Tags:  
  • C#
  • Related