How to use regex in a c#, specifically getting the data inside a double quote? -


For example, we just want to get the data from double quotes in the list of strings:

  string result = string Empty; & Lt; String & gt; Wire = new list & lt; String & gt; (); Strings.add ("string = \" string \ ""); String.ed ("stringwithspace = \" string with location \ ""); Strings.add ("untrimmedstring = \" untrimmed string \ ""); String.ed ("other contimed string = \" here it is \ "); Strings.add ("number = \" 13 \ ""); Strings.add ("empty = \" \ ""); String.add ("whitespace = \" \ ""); Stringbuilder z = new stringbiller (); Forrest (string x in strings) {if (string in the double string inside x) {// regex here z.append (x + "\ n"); }}  

and the result will be:

string = "string"
stringwithspace = "string with location"
untrimmedstring = "untrimmed < / P>

Any way we can do this?

Or something is a lot more thankful.

If string is guaranteed not to be double quotation marks within double quotes, you can use the following reggaeks to capture the trimmed wire inside the double quotes.

^ (\ w +) = "\ s * ([^" + +] \ S * "$

$ 2 or < The code of sorting will be done in Code> Mail [2] - Make sure its length is not zero and the entire string is not replaced with $ 1 = "$ 2" and it does not To add (I do not speak c #)

This regex assumes that

  1. The first part is a word in which only alphanumeric Characters and underscores include Es.
  2. The string inside the double quotes is free of double quotes.

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -