.net - RegEx Pattern to match a string -


i looking regex pattern match string. string, defined in quotes. i'm trying parse these strings:

print "test" print "hello":print "world" 

the pattern have is: "\".*\"". parses first line fine. returns /"test"/, second line, returns /"hello":print "world"/ incorrect. needs match what's between first quote , second quote. appears matching whatever between first quote , last quote in entire line.

any appreciated. if matters, .net regex.

 "[^"]*" 

the .* greedy. matches right end of string, because nothing tells stop @ inbetween ". [^"]* greedy, - not arbitrary.

alternatively use non-greedy matching

 ".*?" 

also see msdn on quantifiers.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -