I have encountered the following regex in the company's code base.
(?:.*)(\\bKEYWORD\\b(?:\\s+)+(?:.*)+;)(?:.*)
Breakdown of Regex:
Non Capturing group:
(?:.*)Capturing group
(\\bKEYWORD\\b(?:\\s+)+(?:.*)+;)2.1 Non Captuing group:
(?:\\s+)+2.2 Non Capturing group:
(?:.*)+Non Capturing group:
(?:.*)
The above regex goes into catastrophic bactracking when it fails to match ; or the test sample becomes too long. Check below the two test samples:
1. -- KEYWORD the procedure if data match between Type 1 and Type 2/3 views is not required.
2. KEYWORD SET MESSAGE_TEXT = '***FAILURE : '||V_G_ERR_MSG_01; /*STATEMENT TO THROW USER DEFINED ERROR CODE AND EXCEPTION TO THE CALLER*/
I went though Runaway Regular Expression's article aswell and tried to use to Atomic Grouping but still no results. Can anybody help me how to fix this regex ?