Regular expression to replace multiple lines that match a pattern
regex
Solution
You can match:
^(Expropriations[\d\D]*?\))
and replace it with:
[$1]
`\d\D` matches any single char including the newline.
Problem
If I have a bunch of text like this ``` The cat sat on the mat Expropriations for international monetary exchange ( Currenncy: Dollars, Value: 50,000) The cat sat on the mat Expropriations for international monetary exchange ( Currenncy: Yen) The cat sat on the mat ``` Is there a Regular Expression I could use in the Find/Replace feature of my text editor (Jedit) to identify all of the lines that begin with the word `Expropriations` and end with a closing parenthesis and then put those lines inside square brackets so that they look like this: ``` The cat sat on the mat [Expropriations for international monetary exchange ( Currenncy: Dollars, Value: 50,000)] The cat sat on the mat [Expropriations for international monetary exchange ( Currenncy: Yen)] The cat sat on the mat ``` The tricky thing is that the closing parenthesis could fall at the end of the same line as the word 'Expropriations' or at the end of the next line. (there might even be more than one line before the parentheses are closed)