Home> php教程> PHP源码> body text

Remove the last comma from the String attribute

大家讲道理
Release: 2016-11-09 10:24:23
Original
1340 people have browsed it

It can also be other symbols. When you have this kind of problem, you should consider changing the storage location first (you can split it into arrays according to the specified string, and only add delimiters when the length is greater than 1, otherwise there is no need to add it at the end)

Boolean isNotEmpty = StringUtils.isNotBlank(this.version); Boolean lastIndex = false; if(isNotEmpty){ lastIndex = ",".equals(this.version.substring(version.length()-1)); } if(isNotEmpty && lastIndex){ return this.version.substring(0,version.length()-1); }else{ return this.version; }
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!