# Problem i face in serial communication

**URL:** <https://discourse.processing.org/t/problem-i-face-in-serial-communication/17023>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [January 11, 2020, 2:34pm UTC](https://discourse.processing.org/t/problem-i-face-in-serial-communication/17023 "2020-01-11T14:34:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 11, 2020, 3:35pm UTC](https://discourse.processing.org/t/problem-i-face-in-serial-communication/17023/2 "2020-01-11T15:35:17Z")

</div>

Hello,

You receive a string which includes a newline character ( ‘\n’ )

You need to remove the newline character ( ‘\n’ ) that is in the received string before splitting it so you can convert to an int.

Example:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b9b172a53e78ef1673e42d36421bcb8b0265be9e.png)

[https://processing.org/reference/trim\_.html](https://processing.org/reference/trim_.html)  
[https://processing.org/reference/String.html](https://processing.org/reference/String.html) (discusses newline character and escape sequences such as \n)

🙂

```auto
String s1 = "123,456,890\n";
String [] list1 = split(s1, ',');

printArray(list1);
println(int(list1[2]));
println();

String s2 = "123,456,890\n";
s2 = trim(s2);

String [] list2 = split(s2, ',');

printArray(list2);
println(int(list2[2]));
println();

```

---

_[View the full topic](https://discourse.processing.org/t/problem-i-face-in-serial-communication/17023)._
