# How to remove tab \[CR\]\[LF\]character from String()?

**URL:** <https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317>\
**Category:** questions\
**Tags:** language\
**Created:** [June 14, 2023, 10:25pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317 "2023-06-14T22:25:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorge-paladino](https://clarionhub.com/user_avatar/clarionhub.com/jorge-paladino/32/2847_2.png) [@jorge-paladino](https://clarionhub.com/u/jorge-paladino)\
**Post date:** [June 14, 2023, 10:25pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/1 "2023-06-14T22:25:09Z")

</div>

For example, inside a json return from a webservice, there is a "tab" before the json{}, I tried using left() but it did not work.  
Does anyone know how to do it?  
thanks  
 ![06013a79-4719-47cf-ab4f-2e33e398865f](https://clarionhub-uploads.s3.dualstack.eu-north-1.amazonaws.com/original/2X/f/f6c0744fcdcc76f51d0d634f8392fbeed585bcce.jpeg)

This Tab disturbs the component that reads the json{} and the component returns an error....

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [June 14, 2023, 10:57pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/2 "2023-06-14T22:57:24Z")

</div>

If you have StringTheory, then look at the .Replace method.  
st.Replace(‘\<09\>’,‘’) !tabs  
st.Replace(‘\<0Dh,0Ah\>’,‘’) ! CR/LF

If you don’t have StringTheory, you can check out the SystemStringClass.Replace that comes with C10 or newer.

If you don’t have that, then you’ll need to use a loop and InString to find and replace the occurrences.

---

<div class="post-metadata">

**Author:** ![anon77170705](https://clarionhub.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@anon77170705](https://clarionhub.com/u/anon77170705)\
**Post date:** [June 14, 2023, 11:27pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/3 "2023-06-14T23:27:45Z")

</div>

> [@jorge-paladino](#):
>
> Does anyone know how to do it?

The filtering characters is not a complex task. The FilterClass in following test program  
[test.clw](https://clarionhub.com/uploads/short-url/jTPZyX5uiKiTkg0Pf5gd6V4xAwk.clw) (3.5 KB)  
allows to set characters which must be filtered from a string.

---

<div class="post-metadata">

**Author:** ![jorge-paladino](https://clarionhub.com/user_avatar/clarionhub.com/jorge-paladino/32/2847_2.png) [@jorge-paladino](https://clarionhub.com/u/jorge-paladino)\
**Post date:** [June 15, 2023, 1:00am UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/5 "2023-06-15T01:00:46Z")

</div>

Woohoo!  
I found!

```
 str.SetValue(stReturn)
 stReturn = **str.left(,st:cr + st:lf + st:tabs + st:spaces)**

```

Thank you all

---

<div class="post-metadata">

**Author:** ![Mike\_Duglas](https://clarionhub.com/user_avatar/clarionhub.com/mike_duglas/32/1061_2.png) [@Mike\_Duglas](https://clarionhub.com/u/Mike_Duglas)\
**Post date:** [June 15, 2023, 10:40am UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/6 "2023-06-15T10:40:28Z")

</div>

> [@jorge-paladino](#):
>
> For example, inside a json return from a webservice, there is a “tab” before the json{},

Something wrong in your way of a service response retrieving.

---

<div class="post-metadata">

**Author:** ![jorge-paladino](https://clarionhub.com/user_avatar/clarionhub.com/jorge-paladino/32/2847_2.png) [@jorge-paladino](https://clarionhub.com/u/jorge-paladino)\
**Post date:** [June 15, 2023, 11:51am UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/7 "2023-06-15T11:51:18Z")

</div>

Good morning my friend Mikee!  
I use the same method to retrieve for all WS, the problem is that the return of this specific WS comes with CR/LF before Json, using st.Left( ,st:cr + st:lf + st:tabs + st :spaces) from stringTheory, it is possible to remove this.  
But if there is another method I’m happy to learn!!

Hugs

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [June 15, 2023, 1:34pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/8 "2023-06-15T13:34:09Z")

</div>

I think what Mike is sayings, is that whatever is consuming your JSON and throwing errors because of the tab and cr/lf characters is the problem.  
Tab and CR/LF are valid whitespace in a JSON string. Just try it with any JSON validator and it passes.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [June 15, 2023, 2:45pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/9 "2023-06-15T14:45:11Z")

</div>

This is one of my favorite techniques, and it has more than one type of use.  
In addition to a filter, it makes for a nice substitution matrix (for example, substituting only “legal” characters for a file name or label).

---

<div class="post-metadata">

**Author:** ![anon77170705](https://clarionhub.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@anon77170705](https://clarionhub.com/u/anon77170705)\
**Post date:** [June 15, 2023, 3:04pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/10 "2023-06-15T15:04:12Z")

</div>

Almost all algorithms were invented in the 60s and early 70s… I was lazy and used bytes as an element type for the map array. Bitmaps are enough for filtering. And, judging by the call parameters, the StringTheory class uses the bitmap for replacing. The question only in handling of the text in quotes and other kinds of brackets where it must be taken as is.

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [June 16, 2023, 12:03pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/11 "2023-06-16T12:03:57Z")

</div>

> [@Rick\_UpperPark](#):
>
> I think what Mike is sayings, is that whatever is consuming your JSON and throwing errors because of the tab and cr/lf characters is the problem.  
> Tab and CR/LF are valid whitespace in a JSON string.

It’s not actually as simple as that. According to [json.org](http://json.org), json begins with either a { or a [. You can end up with whitespace between names / values, but strictly not before or after the JSON document itself.

To be fair there are lots of JSON specifications, and of course pretty much any parser will simply ignore whitespace before the first { or [, but it’s not clear-cut to say “json allows it”.

Equally you are not allowed to have tab, CR or LF _inside_ a string label or value. Those are encoded as \t, \r and \n.

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [June 16, 2023, 1:46pm UTC](https://clarionhub.com/t/how-to-remove-tab-cr-lf-character-from-string/6317/12 "2023-06-16T13:46:53Z")

</div>

Agreed. Jorge’s example showed the tab character “outside” of the JSON data. That’s what I was running with. 🙂
