How to substring a string to the second point (.) in Java?
•
Java
I have a string with many segments by dots (.) Separate as follows:
I want to get a substring up to the second point, such as codes FIFA.
How do I get to the substring of the second point?
Solution
Matcher m = Pattern.compile("^(.*?[.].*?)[.].*")
Matcher m = Pattern.compile("^(.*?[.].*?)[.].*") .matcher("codes.FIFA.buf.OT.1207.2206.idu"); if (m.matches()) { return m.group(1); }
http://ideone.com/N6m8a
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码