Java:如何正则表达式或子字符串利用此字符串?
"Current Peak : 830 300"
我怎样才能得到这两个数字,但没有空格。 (每个子字符串之间有 5 个或更多空格)
使用 apache 的 StringUtils 我到目前为止得到:
String workUnit =
StringUtils.substringAfter(thaString,
":");
这给出了:
"830 300"
但仍然有很多空格并且没有分隔。
"Current Peak : 830 300"
How can I get hold of the two numbers, but without the spaces. (There are 5 or more spaces in between each substring)
Using apache's StringUtils I got so far:
String workUnit =
StringUtils.substringAfter(thaString,
":");
This gives back:
"830 300"
but still with a lot of spaces and not separated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
或者只使用核心java:
Or just using core java:
未经测试,但这应该给你两个数字:
Untested, but this should give you your two numbers:
你可以这样做:
You can do something like this: