开发者

How to make sure that string is valid

开发者 https://www.devze.com 2023-01-09 11:15 出处:网络
I\'m pa开发者_Python百科rsing XML and for now I use nodeTextValue.length() > 0 to check whether the nodeTextValue is valid string, but I\'m having issues with \\n \\r and so on, preceding and follo

I'm pa开发者_Python百科rsing XML and for now I use nodeTextValue.length() > 0 to check whether the nodeTextValue is valid string, but I'm having issues with \n \r and so on, preceding and following nodeText, is there an existing class to trim string on both ways not just after so it returns the valid string

I'm using stax


trim() will remove leading and trailing whitespace.


You can accomplish this by using the trim function on strings. I would also recommend googling Java regular expressions for validating strings.


!nodeTextValue().trim().equals("").
0

精彩评论

暂无评论...
验证码 换一张
取 消