How to replace 1st four spaces ONLY in each line w/ nothing?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

How to replace 1st four spaces ONLY in each line w/ nothing?

Post by jeffy »

I have some java source code that is indented with spaces. But before EVERY line, there are four additional spaces (this is the format required by stackoverflow, in order to post code, so it actually displays like code).

Code: Select all

    /**
       <P>A function.</P>
     **/
    public void myFunction()  {
       for(...)   {
          ...
       }
I am trying to eliminate those first four spaces with "^[FOURSPACES]" --> "", but it's making that replacement repeatedly on every line, which is eliminating too many spaces.

It should result in this

Code: Select all

/**
   <P>A function.</P>
 **/
public void myFunction()  {
   for(...)   {
      ...
   }
but actually results in this

Code: Select all

/**
   <P>A function.</P>
 **/
public void myFunction()  {
   for(...)   {
  ...
   }
Does anyone know how to do this replacement only once per line? Thank you for helping me.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Your regex should work, but, as you say, it doesn't. It did in TextPad 6.

Use this instead:
Find what: ^_{4}(.*) [Replace the underscore with a space]
Replace with: $1
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

Post by jeffy »

Thank you, ben_josephs. I thought it might be a bug. I've reported it.
User avatar
bbadmin
Site Admin
Posts: 1020
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

Thanks for reporting this bug. It will be fixed in the next upgrade.
Post Reply