Removing space on beginning of each line using regex
Application Type
Traditional Web

Hi All

 Can any one help me to remove the space on beginning of each line by using regex or js.

 Assume I have line like this below

Hi   

  How are you 

Fine  


But I want it as:

Hi

How are you

Fine 


Thanks in advance 

Hi Balagi,

My suggestion is that you can try String_Split with NewLine() as Delimiters (the list result should be filter out empty line as mentioned in this post). Then you can use String_Join with NewLine() as Separator and make sure to TrimStart the value of each item in the list.

Regards,

Khuong

Hi @Khuong Truong 

   As you said I am doing above steps ... but when I am passing the list of text after string split to the string join having error.. string join asking me text record list instead of text list.. 

If possible can you share me any oml fine for better understanding l.

Thanks

I found the way to convert @Khuong Truong thanks a lot.

mvp_badge
MVP

Hi Daniel 

   Each of the line is from same paragraph. So if we use trim It trims only on beginning of paragraph 

Thanks 

Hi Balagi,

My suggestion is that you can try String_Split with NewLine() as Delimiters (the list result should be filter out empty line as mentioned in this post). Then you can use String_Join with NewLine() as Separator and make sure to TrimStart the value of each item in the list.

Regards,

Khuong

Hi @Khuong Truong 

   As you said I am doing above steps ... but when I am passing the list of text after string split to the string join having error.. string join asking me text record list instead of text list.. 

If possible can you share me any oml fine for better understanding l.

Thanks

I found the way to convert @Khuong Truong thanks a lot.

Hi All,

for completeness, here's the answer on the question in the original post : how to do it with regex_replace

"^ +"
  • the ^ means only at beginning of line
  • the space is the character we are looking to match
  • the + means we want to match any number of that character
  • also note, that if you want this on every line of a multiline text, you have to set multiline boolean to True

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.