I have been trawling through documentation and posts in stackoverflow on this but can’t seem to get the syntax right. I want replace everything between the return keyword and trailing ; in something like this:
return new Foo() {
void bar(){
System.out.print("Hello World");
}
};
This is my most informed attempt so far but it doesn’t work: return(.*?);
Any help much appreciated 😉
Use the “dot matches new line” switch
(?s)and look-arounds:This entire regex matches anything between but not including
returnand;across multiple lines.