Remove spaces and tabs at the beginning of all lines

Find, replace, find in files, replace in files, regular expressions

Remove spaces and tabs at the beginning of all lines

Postby ftpaccess » Fri Mar 23, 2012 8:32 am

I have records which have spaces in front of them:

[space]Mike Dawson
Allen toole
[space]Chasey White
Robert Weyes

I want to bring them to this format:

Mike Dawson
Allen toole
Chasey White
Robert Weyes

There is trim trailing spaces but no trim preceding spaces.
ftpaccess
Newbie
 
Posts: 7
Joined: Fri Apr 30, 2010 12:38 am

Re: Remove spaces and tabs at the beginning of all lines

Postby Mofi » Fri Mar 23, 2012 9:41 am

Run an UltraEdit regular expression Replace All searching for %[ ^t]+ and an empty replace string.

Or if you prefer Unix or Perl regular expression engine use as search string ^[ \t]+ and also an empty replace string.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Remove spaces and tabs at the beginning of all lines

Postby MickRC3 » Fri Mar 23, 2012 10:12 am

This can be performed without writing a regular expression. You highlight the text and then select Format, Remove Indents and pick a number larger than the biggest gap, say 20 or so. This will move all of the lines flush to the left margin. You won't lose any characters except tabs or spaces from the beginnings of the lines, even when they are already flush.
MickRC3
Newbie
 
Posts: 8
Joined: Fri Feb 10, 2012 2:22 pm


Return to Find/Replace/Regular Expressions