开发者

How to split a string and count the parts?

开发者 https://www.devze.com 2023-02-12 03:14 出处:网络
How can I do the same as the following开发者_StackOverflow社区 PHP snippet in JSP? $to_len = count(explode(\",\",$to));

How can I do the same as the following开发者_StackOverflow社区 PHP snippet in JSP?

$to_len = count(explode(",",$to));

Basically, it splits a variable with the name to on delimiter , and then counts the parts.


Using JSTL functions:

${fn:length(fn:split(to, ','))}

Another way is through scriptlets, but it is not recommended - to.split(",").length()

0

精彩评论

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