Page 1 of 1

How do you remove leading spaces from multiple lines?

Posted: Wed Sep 07, 2016 6:09 am
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.

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

Posted: Wed Sep 07, 2016 4:35 pm
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>

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

Posted: Wed Sep 07, 2016 6:44 pm
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.