I would like to match everything between and including curly braces in eclipse find and replace (it can be assumed that there are no inner curly braces but any other character including all types of whitespace.
int SomeMethodName() {
// TODO Auto-generated method stub
re开发者_JS百科turn asdfasdf.rearoiula12123893;
}
Right now I am trying this and it only matches curly braces with nothing in them \{[.\s]*\}
The .
inside a character class means a .
literal, not a wildcard. You need something more like:
\{.*?\}
Depending on how Eclipse treats new line characters you might need to change it to:
\{(.|\r\n?|\n)*?\}
This should work. Tested using Regex Powertoy here.
\{[\s\W\w]*\}
EDIT:
\{[\s\w\. /=(":);]*\}
should stop at the nearest closing brace. The piece after the space has all the miscellaneous non-word characters, so you might have to add to that depending on the nature of what you're parsing (e.x. a weird String).
精彩评论