could someone please tell me how can I remove the first two characters of a word that is in a list?
For example I have the following list:
List = ['\ nNew', '\ nIndustrial', '\ nColombia']
how can I remove the '\ n' from each word?
CodePudding user response:
In javascript, you can use map to iterate through the list & use slice to remove the first few characters. See code below:
List = ['\ nNew', '\ nIndustrial', '\ nColombia'];
newList = List.map(item => item.slice(2,));
console.log(newList);
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
Something simple like
for (String str : list) {
str.replace("\n", "");
}
would work if this is in Java.
Or even list.forEach(str -> str.replace("\n", ""));
.