I have an array such as def list = ["pathfinding", " Gameplay", "Community"] which I would like to iterate and eliminate the whitespace at the beginning of each element. So I though it would be easy using something like:
for(x in list){
x = x.replace("\\s", "")
println x
}
but I keep getting this output
pathfinding
Gameplay
Community
I do now know much about regex what I tried different ones I found here in SO and none worked so I guess the regex is not the problem here... any hints?
"".trim()if I remember correctly so you don't need to mess with regex.