itro itro - 2 years ago 79
Java Question

How to substring a string to the second dot (.) in Java?

I have a String which has many segments separated by a dot (

) like this:


I want to get a substring only until second dot, like

How to substring just until the second dot?

Answer Source
 Matcher m = Pattern.compile("^(.*?[.].*?)[.].*")
 if (m.matches()) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download