How do I remove white space in a Perl string?

后端 未结 12 1942
离开以前
离开以前 2020-12-31 09:34

If I declared a variable $myString with the value \'3 \' (notice the white space). Is there any function to remove the white space for the return v

12条回答
  •  太阳男子
    2020-12-31 09:47

    $myString =~ s/^\s*(.*?)\s*$/$1/;
    

    This will trim whitespace from both sides.

    from just the right:

    $myString =~ s/\s*$//;
    

提交回复
热议问题