# TOF 🤦‍♂️: Replace EndOfLines: Strings end in EndOfLines?!?

**URL:** <https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172>\
**Category:** General Programming\
**Created:** [15 November 2021 18:58 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172 "2021-11-15T18:58:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkusWinter](https://ifnotnil.com/user_avatar/ifnotnil.com/markuswinter/32/32_2.png) [@MarkusWinter](https://ifnotnil.com/u/MarkusWinter)\
**Post date:** [15 November 2021 18:58 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/1 "2021-11-15T18:58:05Z")

</div>

see [Replace EndOfLines: Strings end in EndOfLines?!? - Windows - Xojo Programming Forum](https://forum.xojo.com/t/replace-endoflines-strings-end-in-endoflines/66697)

I find the “answers” less than impressive. Could SOMEONE tell the OP that he is using the wrong approach and point him to SPLIT and TRIM?

---

<div class="post-metadata">

**Author:** ![jmadren](https://ifnotnil.com/user_avatar/ifnotnil.com/jmadren/32/65_2.png) [@jmadren](https://ifnotnil.com/u/jmadren)\
**Post date:** [15 November 2021 20:16 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/2 "2021-11-15T20:16:56Z")

</div>

I think Kem’s RegEx solution is better than SPLIT and TRIM. As to the issue the OP was having, I posted a follow-up.

---

<div class="post-metadata">

**Author:** ![MarkusWinter](https://ifnotnil.com/user_avatar/ifnotnil.com/markuswinter/32/32_2.png) [@MarkusWinter](https://ifnotnil.com/u/MarkusWinter)\
**Post date:** [15 November 2021 20:38 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/3 "2021-11-15T20:38:23Z")

</div>

True. I was under the mistaken impression that Trim would also deal with other space characters like non-breaking space, thin space, etc that his regex will not deal with, but I just tried to make sure and it seems not.

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [15 November 2021 20:40 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/4 "2021-11-15T20:40:20Z")

</div>

a regex just seems overkill

```auto
strText=ReplaceAll( ReplacelineEndings(strText, EndOfLine), EndOfLine + " ", EndOfLine)

```

---

<div class="post-metadata">

**Author:** ![jmadren](https://ifnotnil.com/user_avatar/ifnotnil.com/jmadren/32/65_2.png) [@jmadren](https://ifnotnil.com/u/jmadren)\
**Post date:** [15 November 2021 20:49 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/5 "2021-11-15T20:49:28Z")

</div>

> [@npalardy](#):
>
> a regex just seems overkill

RegEx may be overkill for only a single space removal, but that was after he removed all double spaces using a loop. Kem’s RegEx code would replace both the loop and his final ReplaceAll.

Plus, the OP was doing pretty much what you are, except for converting the EndOfLines to the current platform. His issue stems from some anomaly that is yet to be confirmed.

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [15 November 2021 20:50 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/6 "2021-11-15T20:50:50Z")

</div>

I’ve only glanced at that thread

Busy pulling my hair out over other things 😛

---

<div class="post-metadata">

**Author:** ![MarkusWinter](https://ifnotnil.com/user_avatar/ifnotnil.com/markuswinter/32/32_2.png) [@MarkusWinter](https://ifnotnil.com/u/MarkusWinter)\
**Post date:** [15 November 2021 21:42 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/7 "2021-11-15T21:42:28Z")

</div>

> [@npalardy](#):
>
> Busy pulling my hair out over other things 😛

I don’t think you can afford that …

… come to think of it, me neither … 👴

---

<div class="post-metadata">

**Author:** ![trishaduke](https://ifnotnil.com/user_avatar/ifnotnil.com/trishaduke/32/41_2.png) [@trishaduke](https://ifnotnil.com/u/trishaduke)\
**Post date:** [15 November 2021 23:49 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/8 "2021-11-15T23:49:53Z")

</div>

> [@jmadren](#):
>
> Kem’s RegEx code

which code is that??

---

<div class="post-metadata">

**Author:** ![MarkusWinter](https://ifnotnil.com/user_avatar/ifnotnil.com/markuswinter/32/32_2.png) [@MarkusWinter](https://ifnotnil.com/u/MarkusWinter)\
**Post date:** [16 November 2021 00:10 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/9 "2021-11-16T00:10:32Z")

</div>

Follow the link.

---

<div class="post-metadata">

**Author:** ![anon72844311](https://ifnotnil.com/letter_avatar_proxy/v4/letter/a/9de0a6/32.png) [@anon72844311](https://ifnotnil.com/u/anon72844311)\
**Post date:** [17 November 2021 16:36 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/10 "2021-11-17T16:36:50Z")

</div>

Happy with that response now Markus? 🙂

---

<div class="post-metadata">

**Author:** ![MarkusWinter](https://ifnotnil.com/user_avatar/ifnotnil.com/markuswinter/32/32_2.png) [@MarkusWinter](https://ifnotnil.com/u/MarkusWinter)\
**Post date:** [17 November 2021 19:30 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/11 "2021-11-17T19:30:13Z")

</div>

> Now that we know its a custom app made in Xojo, here we go, I knew it reminded me of something that was in the back of my mind [feedback://showreport?report\_id=51479]. It’s a known bug from 2018!!  
> `Extra line added when copy and pasting from and to a textarea`  
> `When you copy and paste from and to a textarea an additional blank line is added to the content but only if that content is over multiple lines.`  
> This perfectly explains why you only see it on the multiline example above.

Very nice and definite answer from you on the OPs problem. 👍

So happy with the answer? Yes.  
Happy it’s a bug? No.  
Surprised it’s an unfixed bug? No.  
Happy with Trim? No.

But Trim is easy enough to fix, so next time I fire up Xojo I might just write one …

---

<div class="post-metadata">

**Author:** ![Emile](https://ifnotnil.com/letter_avatar_proxy/v4/letter/e/58956e/32.png) [@Emile](https://ifnotnil.com/u/Emile)\
**Post date:** [18 November 2021 11:26 UTC](https://ifnotnil.com/t/tof-replace-endoflines-strings-end-in-endoflines/2172/12 "2021-11-18T11:26:25Z")

</div>

And now we know the bug is in Xojo 2018 (the external tool the OP use)…👹
