How do you remove leading spaces from multiple lines?

A place to try and solve your RegEx problems.
Post Reply
irish003
Posts: 2
Joined: Wed Sep 07, 2016 5:51 am

How do you remove leading spaces from multiple lines?

Post by irish003 »

I need the RegEx expression for removing leading spaces on each line for many different files. I have tried many different expressions, but none have worked. Can anyone provide the correct syntax?

I am using Batch commands/Batch Editor feature where you enter the RegEx expression and replacement value.
I have the Regular Expression and Multi-Line Anchors checked.

I want to trim the leading spaces up to the first non-space character from every line, in every file in a specified Start Location (Folder).

I have tried ^[ ]+ and ^[ \t]+ but they don't work.

Any help is appreciated.
User avatar
DigitalVolcano
Site Admin
Posts: 1717
Joined: Thu Jun 09, 2011 10:04 am

Re: How do you remove leading spaces from multiple lines?

Post by DigitalVolcano »

It works for me with the settings you've suggested. Are you sure you haven't got something else limiting the search like a date or file filter?


txc file:

Code: Select all

<?xml version="1.0" encoding="utf-16"?>
<TextCrawlerBatch Version="3.0">
  <command name="FindRep" enabled="True">
    <find xml:space="preserve">^[ ]+</find>
    <replace></replace>
    <flags>MultiLine</flags>
  </command>
  <command name="FindRep" enabled="True">
    <find xml:space="preserve">^[ \t]+</find>
    <replace></replace>
    <flags>MultiLine</flags>
  </command>
</TextCrawlerBatch>
irish003
Posts: 2
Joined: Wed Sep 07, 2016 5:51 am

Re: How do you remove leading spaces from multiple lines?

Post by irish003 »

You were correct, thanks a bunch. I had a filter on as you said. I was going buggy trying to figure out what was wrong.
Post Reply