Stuck with 2 simple regex for text editing

Hi there, I need to edit text with regex. It’s my first time working with expressions and I can’t seem to solve these two.

In my text there are a number of indications between square brackets as follows: [1], [2], [3], etc.
I want to remove them with one regex. My first thought was by using a character class, but after some trial and error I can’t seem to make it work.

I also want to remove all indications of type CHAPTER I. LOOMINGS , CHAPTER II. THE CARPET-BAG, … , CHAPTER CXXXV. THE CASE-THIRD DAY
I need to use an anchor to indicate that the pattern should be at the beginning of a line. This is what I had written so far: (?im)^CHAPTER
I’m able to remove the word CHAPTER, but I’m unable to find how to remove all the characters that come after.

Thanks in advance!

Brent,

Welcome to the ActiveState Platform! Our community tends to focus on issues with building runtime environments rather than specific programming problems. You may want to try posting your question on Stack Overflow or similar forum instead.

Hope that helps,