# Remove all characters after a new line

**URL:** <https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424>\
**Category:** Need help\
**Created:** [September 8, 2017, 3:55pm UTC](https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424 "2017-09-08T15:55:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ethan/32/104872_2.png) [@ethan](https://forum.bubble.io/u/ethan)\
**Post date:** [September 8, 2017, 3:55pm UTC](https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424/1 "2017-09-08T15:55:25Z")

</div>

I am pulling content from an API (JSON) and I want to remove everything that’s after a new line. This is a snippet of what it would look like in the API:

```json
...
"text": "In pellentesque massa lorem, nec feugiat risus dignissim ac.\n\nMorbi justo felis, scelerisque vitae ligula sit amet, porttitor molestie sapien. Pellentesque tristique nisl et leo hendrerit consectetur.",
...

```

When I use the _Text_ element on Bubble to display the data, this is what it looks like:

> In pellentesque massa lorem, nec feugiat risus dignissim ac.
> 
> Morbi justo felis, scelerisque vitae ligula sit amet, porttitor molestie sapien. Pellentesque tristique nisl et leo hendrerit consectetur.

What I want to do is only display the first line from the `text` field, so it can look like this:

> In pellentesque massa lorem, nec feugiat risus dignissim ac.

I was thinking about using `:extrax with Regex` function, but I haven’t been able to find the right regex. Unless, there is a better method of handling this.

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [September 8, 2017, 7:32pm UTC](https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424/2 "2017-09-08T19:32:22Z")

</div>

`[^\n]` and if you were to repeat the task in say a multiline text box, into repeating group for instance `[^\n]+` should do the trick.

---

<div class="post-metadata">

**Author:** ![ethan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ethan/32/104872_2.png) [@ethan](https://forum.bubble.io/u/ethan)\
**Post date:** [September 8, 2017, 8:36pm UTC](https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424/3 "2017-09-08T20:36:46Z")

</div>

Excellent, using `[^\n]+` worked, thank you. I also added `:first item` because it would still show the remaining content after the first line but in commas, for example:

**Using just the `:extrax with Regex`**

> In pellentesque massa lorem, nec feugiat risus dignissim ac.,Morbi justo felis, scelerisque vitae ligula sit amet, porttitor molestie sapien. Pellentesque tristique nisl et leo hendrerit consectetur.

**Using `:extrax with Regex:first item`**

> In pellentesque massa lorem, nec feugiat risus dignissim ac.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [November 17, 2017, 3:55pm UTC](https://forum.bubble.io/t/remove-all-characters-after-a-new-line/17424/4 "2017-11-17T15:55:35Z")

</div>

Closed on November 17, 2017, 3:55pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
