# Text column to remove line breaks & new paragraphs?

**URL:** https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457
**Category:** Ask for Help
**Created:** [January 20, 2022, 11:34am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457 "2022-01-20T11:34:59Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 11:34am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/1 "2022-01-20T11:34:59Z")

</div>

Is there as special text column that can ‘clean’ a text string to remove text formatting, e.g. line breaks and new paragraphs?

I am trying to export data from a Glide Data table by copying the contents of a Template column to clipboard. The template column is fed by content from a few different columns. It works well except when a user has inputted some text that includes line breaks or new paragraphs! If they do, pasting into excel disrupts the formatting.

(Not interested in other ways to export data at this stage!)

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 20, 2022, 11:51am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/2 "2022-01-20T11:51:21Z")

</div>

> **[Trim Whitespace column • Glide](https://www.glideapps.com/plugins/trim)**
>
> Remove whitespace around text.

I haven’t tested with things like line breaks, but I would assume it handles them.

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 11:53am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/3 "2022-01-20T11:53:17Z")

</div>

Yup, tried that. no luck.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 20, 2022, 11:55am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/4 "2022-01-20T11:55:56Z")

</div>

oh, really?

Okay, next option would be the [Extract Matching Text](https://www.glideapps.com/plugins/regex) plugin with an appropriately crafted regex. Are you familiar with regex, or would you like some help with that?

`^\s*(.*)\s*$` should do the trick.

 ![Screen Shot 2022-01-20 at 8.02.04 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/1/016726fc51455f57bd41488e2b4f29764ad9dd1a.png)

 ![Screen Shot 2022-01-20 at 8.02.16 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/6/363dc1602324c715ce5bd73f82ab9e3ebbd4b91a.png)

Actually, the Trim Whitespace plugin works for me. Can you share some examples of strings that it doesn’t work for?

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 12:12pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/5 "2022-01-20T12:12:49Z")

</div>

Oh thanks for taking the time Darren.

An example of some tricky text:

"We need to engage Urologists and not just Oncs.

Office-based urologists carry out cystoscopy or transurethelial resection and refer patients with suspected UC to hospital."

In my version, the whitespace column does nothing to that text. The paragraph breaks remain in tact…

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 20, 2022, 12:14pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/6 "2022-01-20T12:14:52Z")

</div>

oh, I see. So you actually want to condense line breaks into a single white space, yeah?

yeah, Trim won’t do that. You need a regex. It’s time for my little boys bedtime story now, but I can come back with an appropriate regex a bit later…

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 12:19pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/7 "2022-01-20T12:19:24Z")

</div>

I will try one other thing first, see if I can use a template column to replace all paragraph breaks…

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 12:22pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/8 "2022-01-20T12:22:21Z")

</div>

The template option didn’t work…!

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 20, 2022, 12:25pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/9 "2022-01-20T12:25:10Z")

</div>

[Replace All](https://www.glideapps.com/plugins/replace-all) will do it.

 ![Screen Shot 2022-01-20 at 8.23.29 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/8/98224f0f4fe3db4503fa7b6865198bd24cb3afa2.png)

The replacement value is just a single space.  
This won’t get rid of leading/trailing single spaces, but you could then run that through Trim to clean those up.

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 12:27pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/10 "2022-01-20T12:27:50Z")

</div>

I will try this (need to run for 2 hours first though) but THANKS^6

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 4:33pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/11 "2022-01-20T16:33:17Z")

</div>

Excellent Darren - THANK YOU.

Your proposal to use the ‘Replace All’ text column works well. This column accepts special rich text format arguments. I could literally type enter (new line) as the argument to replace and it works perfectly.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 20, 2022, 4:52pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/12 "2022-01-20T16:52:51Z")

</div>

Cool!

Just one thing to be aware of with that approach… if you’re using a literal new line as the argument, and a space as the replacement value, then it will replace _every_ new line with a space. So for example, if you had a block of text that contained 6 new lines, then it would replace that with 6 spaces. Which may or may not be what you want.

If you’d want those 6 new lines condensed into a single space, then I’d recommend using the regex pattern as per my example, ie: `\s+`

`\s` matches _any_ white space character, and `+` is quantifier that means “match 1 or more times”

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 20, 2022, 9:15pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/13 "2022-01-20T21:15:21Z")

</div>

Thanks for the advice. To be clear, I didn’t use any special characters like \s+. I just pressed enter.

Your example of \s+ is for spaces. What is the equivalent for a new line?

Regards,  
Simon.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 20, 2022, 11:49pm UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/14 "2022-01-20T23:49:23Z")

</div>

@Darren_Murphy knows better than me, but it might be one of \n (new line) or \r (carriage return).

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 21, 2022, 1:28am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/15 "2022-01-21T01:28:40Z")

</div>

> [@Simon\_Hill](#):
>
> To be clear, I didn’t use any special characters like \s+. I just pressed enter.

Yes, I understand that.

> [@Simon\_Hill](#):
>
> Your example of \s+ is for spaces. What is the equivalent for a new line?

The equivalent for a new line is exactly the same. As I explained above:

> [@Darren\_Murphy](#):
>
> `\s` matches _any_ white space character, and `+` is quantifier that means “match 1 or more times”

The definition of _any_ whitespace character can vary depending on the regex engine, but it usually includes: space, tab, newline, carriage return & vertical tab.

Your response suggests that I didn’t do a very good job of explaining, so I’ll try again.

Let’s go back to your earlier example, but add a few extra carriage returns:

```auto
"We need to engage Urologists and not just Oncs.

Office-based urologists carry out cystoscopy or transurethelial resection and refer patients with suspected UC to hospital."

```

Here is what that looks like in the Data Editor:

 ![Screen Shot 2022-01-21 at 9.12.59 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/b/fba58e64a8bf62cc00916d75ee0a4481466da224.png)

Now, assuming that I understand correctly, what I believe you are doing is using the Replace All plugin and replacing all occurrences of a newline with a single space. So the column configuration probably looks something like this:

 ![Screen Shot 2022-01-21 at 9.14.22 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/9/59a71ee0e05c971e1d012c3439679164214a27f2.png)

When you apply that approach to our extreme example above, this is the result you will get:

 ![Screen Shot 2022-01-21 at 9.14.37 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/6/56d0b6073c05959fb35b45098086293fb83c2331.png)

Notice that block of empty space after the word Oncs?

That’s because we have replaced 6 newlines with 6 spaces.

If that’s okay, then fine. But if you’d rather not have that odd looking empty space, then that’s where the regex pattern comes in. Here is what that looks like:

 ![Screen Shot 2022-01-21 at 9.15.31 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/e/fe5b82283fd8c301f6bc157e584b44b7ecf3a99d.png)

And here is the result:

 ![Screen Shot 2022-01-21 at 9.15.43 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/4/a4caf3dc6eb8549524479d6dc9f7171405b6711f.png)

When you use `\s+` as the “Replace This” value, and a single space as the “With This” value, that essentially means: “replace any and all sequences of one or more white space characters with a single space”

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [January 21, 2022, 1:33am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/16 "2022-01-21T01:33:19Z")

</div>

> [@ThinhDinh](#):
>
> but it might be one of \n (new line) or \r

\n is a new line, and \r is a carriage return.  
\s is a “superclass” that covers both of the above, and more.

A good analogy would be:

\n = oranges  
\r = apples  
\s = fruit

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 21, 2022, 3:27am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/17 "2022-01-21T03:27:44Z")

</div>

> [@Darren\_Murphy](#):
>
> \n is a new line, and \r is a carriage return.  
> \s is a “superclass” that covers both of the above, and more.
> 
> A good analogy would be:
> 
> \n = oranges  
> \r = apples  
> \s = fruit

That’s super clear, thank you!

---

<div class="post-metadata">

### Author: ![Simon\_Hill](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/simon_hill/32/94730_2.png) [@Simon\_Hill](https://community.glideapps.com/u/Simon_Hill)
#### Post date: [January 21, 2022, 9:39am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/18 "2022-01-21T09:39:48Z")

</div>

My bad. You had already explained it perfectly. For some reason when I first tried the \s+ syntax it didn’t seem to work. Not sure what dumb thing I was doing since when I tried again today, it worked perfectly.

The fruit analogy is great and is super useful! Thank you again.

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)
#### Post date: [January 22, 2022, 9:40am UTC](https://community.glideapps.com/t/text-column-to-remove-line-breaks-new-paragraphs/37457/19 "2022-01-22T09:40:37Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
