/*** Intercept the specified string in a string, intercept the domain name, try to intercept the domain name of different URLs? * For example www.163.com,www.sohu.com.cn * string interception requires the location of the substring () * index, where you need to find the first " ." As the starting index for each domain name, then find the next ("." +1) as the end position * The first point is easy to find, IndexOf, 2nd, with indexof (".", before "." +1) Find*/ Public classStringDemo6 { Public Static voidMain (string[] args) {String http= "Www.163.com"; String HTTP2= "www.sohu.com.cn"; intIndex1 = Http2.indexof (".")); intIndex2 = Http2.indexof (".", Index1+1); String DomainName= HTTP2. substring (index1+1, INDEX2); System.out.println (DomainName); }}
View Code
/**
* In a string to intercept the specified string, domain name interception, try to intercept different URLs of the domain name?
* Like www.163.com,www.sohu.com.cn
* String interception is required with substring ()
* The location of the index, you need to find the first "." As the starting index for each domain name, then find the next ("." +1) as the end position
* First point is easy to find, IndexOf, 2nd, with indexof (".", before "." +1) find
*/
Intercepts the specified string in a string, intercepts the domain name, and attempts to intercept the domain name of the different URLs?