Regular Expression backtracks until overflow in Java
问题 The following expression: ^(#ifdef FEATURE)+?\s*$((\r\n.*?)*^(#endif)+\s*[\/\/]*\s*(end of)*\s*FEATURE)+?$ Overrides the matching buffer when running my compiled .Jar file. The matching string can be similar to: this is a junk line #ifdef FEATURE #endif // end of FEATURE this is a junk line #ifdef FEATURE this is a junk line that should be matched: HOLasduiqwhei & // FEATURE fjfefj #endif // h #endif FEATURE this is a junk line So, the bold strings should match. The error is as follows: at