I have string:
new y",[["new york",0,[]],["new york times",0,[]
I want these string betwent ["
and ",
:
new york
new york times
I tried this function:
public MatchCollection s;
...
s = Regex.Matches(s44, "[\".*?\",");
but I got this error: ArgumentException was unhandled: prasing "[".*?"," - Unterminated [] set
.
Can you help me solve this problem? Thank you very much!
Edit: The string I want dont have ["
and ",
I have already answered this question yesterday, use
Regex.Matches(@"(?<=\["")[^""]+")
Using the @ prefix, you make the string literal, which means in your case the backlashes are handled as other characters and you don't need to escape them. But you need to double the double quotes.
The lookbehind part was already explained, so please don't repost the same question next time.
This is what you want:
output:
new york, new york times
Regex Demo
You need to escape the bracket. Additionally, you need to introduce a group by using the parenthesis. The text you want is than contained in that group: