Matching a unknown range of lines
-
I can't quite figure our how to define the expression to match the following. I have a number of places in files where lines contain "START FAILSAFE" and "STOP FAILSAFE" with a varying number of lines between. I would like to match these lines and replace them with an empty line. Anyone have a suggestion? Thanks!
Public Function MyFunction1() As Integer
'*** START FAILSAFE *********
If Not fsDISABLED Then On Error GoTo FailSafe_Error
'*** STOP FAILSAFE **********
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
Exit functionFailSafe_Error:
'*** START FAILSAFE **********
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
'*** STOP FAILSAFE **********
End FunctionPublic Function MyFunction2() As Integer
'*** START FAILSAFE *********
If Not fsDISABLED Then On Error GoTo FailSafe_Error
'*** STOP FAILSAFE **********
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
Exit function
FailSafe_Error:
'*** START FAILSAFE **********
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
'*** STOP FAILSAFE **********
End Function -
I can't quite figure our how to define the expression to match the following. I have a number of places in files where lines contain "START FAILSAFE" and "STOP FAILSAFE" with a varying number of lines between. I would like to match these lines and replace them with an empty line. Anyone have a suggestion? Thanks!
Public Function MyFunction1() As Integer
'*** START FAILSAFE *********
If Not fsDISABLED Then On Error GoTo FailSafe_Error
'*** STOP FAILSAFE **********
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
Exit functionFailSafe_Error:
'*** START FAILSAFE **********
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
'*** STOP FAILSAFE **********
End FunctionPublic Function MyFunction2() As Integer
'*** START FAILSAFE *********
If Not fsDISABLED Then On Error GoTo FailSafe_Error
'*** STOP FAILSAFE **********
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
A number of lines of code to remain
Exit function
FailSafe_Error:
'*** START FAILSAFE **********
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
A number of lines of code to be deleted
'*** STOP FAILSAFE **********
End FunctionAssuming that the regex engine you are using supports the dotall operator, you can use the following:
'\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*(.*?)'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\*
Alternatively, you could use
'\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*[\w\W]*?'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\*