millimeter
Programmer
Greetings,
I am replacing spaces in a string with underscores:
$userInput = "newname " (notice space)
$userInput =~ s/( )/\_/g;
However if the user leaves space(s) at the end of the string it then is output as; "newname_"
This posses issues as you likely can imagine particularly when writting file names.
How can I remove it/them (in the case there is more than one) from the end of the string?
Thanks in advance.
I am replacing spaces in a string with underscores:
$userInput = "newname " (notice space)
$userInput =~ s/( )/\_/g;
However if the user leaves space(s) at the end of the string it then is output as; "newname_"
This posses issues as you likely can imagine particularly when writting file names.
How can I remove it/them (in the case there is more than one) from the end of the string?
Thanks in advance.