views:

50

answers:

3

I am using regex in Find/Replace in VS IDE. I need to replace the string message="My message" in all aspx files with an empty string. The html looks like this

<input id="test" message="My message"/>

I am trying to use the regex to find for message="{.*}" but it doesn't work.

+1  A: 

Try message="{[^"]*}"

That worked! Can you explain how you arrived at that?
Bob Smith
A: 

use message="[^\"]*"

You can test your regex queries live on the nregex site - http://www.nregex.com/nregex/default.aspx

Scott Ivey
+1  A: 

Because * is greedy it will capture until it finds the last quote, instead of the next quote, which is what you want. By telling the expression to capture all non-quote characters, you can ensure that it only captures up to the next one.

message="{[^"]*}"

Adam Ruth