[英]Splitting a String without .split command
I got a String "1/3" where I want to get only the number 1 我有一个字符串“ 1/3”,我只想得到数字1
Is it possible to get it without using "1/3".split("\\\\/") ? 是否可以不使用“ 1/3” .split(“ \\\\ /”)获得它?
阅读String API:
String.substring(...);
Or with some regex as well: 或使用一些正则表达式:
String s = "1/3";
String m = s.replaceAll("(\\d+)/.+", "$1");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.