TextPad: Find all the lines not starting with a pattern and replace with a back space

textpad

I want to introduce a backspace character at the beginning of the line where a particular pattern is not found. Please advise.

Thanks,
Sagar

Best Answer

If you mean that you want to "remove the first character" then you can do this:

1) Write your regex pattern of what you want to find. For example, if you want to match Remove me at the start of the line, use:

^R\(emove me\)

Here we use ^ to assert the position to the start of the string. We also capture everything apart from the string we wish to keep in a backreference so it can be used later.

2) Replace the matches we find with whatever we grabbed in our backreference, in this case emove me, in effect backspacing the first character.

3) Make sure regular expression is checked and the cursor is at the start of the file, and hit Replace All.

Before

before

After:

enter image description here

Related Topic