Page 1 of 1

replacing first character of line only

Posted: Thu May 09, 2019 8:45 pm
by richardk
When I do regex:

find: ^a
replace: (no character, blank)

on file with:

aaaaa

It replaces all the a's, not just the first one.

I want to replace only the first a, it used to work on textpad.
Not sure why it is not working now.

Posted: Thu May 09, 2019 10:14 pm
by ben_josephs
TextPad removes the a at the beginning of the line. The next a is now at the beginning of the line, so TextPad removes that. And so on. Perhaps TextPad shouldn't behave like this.

There are several ways to solve this. Here are two:
Find what: ^a(.*)
Replace with: $1
Find what: ^a(?=.|$)
Replace with: [nothing]

Posted: Fri May 10, 2019 12:26 am
by richardk
Thanks, that works great!