# Delete spaces in variable value

**URL:** <https://forum.robusta.ai/t/delete-spaces-in-variable-value/476>\
**Category:** Get Help\
**Created:** [November 22, 2022, 1:07pm UTC](https://forum.robusta.ai/t/delete-spaces-in-variable-value/476 "2022-11-22T13:07:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilayda.ipar](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robusta.ai/ilayda.ipar/32/56_2.png) [@ilayda.ipar](https://forum.robusta.ai/u/ilayda.ipar)\
**Post date:** [November 22, 2022, 1:07pm UTC](https://forum.robusta.ai/t/delete-spaces-in-variable-value/476/1 "2022-11-22T13:07:51Z")

</div>

The value of the variable I got from excel is “Castillo Roncancio, Monica Pilar.” (the location of the spaces varies for each line) I split the script by comma, and it says “var str= name. split(”, “); var FirstName= str[0];” I want to capture only the “Castillo Roncancio” data, but I get an error because there is a space. In this case, is there a way to delete the trailing spaces before the comma in a different script or variable value?

**Solutions:**

I solved the problem by using the trim method to eliminate spaces to the right and left of the comma when splitting by comma.

var str = execution.getVariable(“name”);  
str= str.trim();  
var arr = str.split(“,”);  
str = arr[0];  
execution.setVariable(“str”,str);
