// Retrieve domain name (excluding second-level domain names)
Public String Geturldomainname ( String Strhtmlpagepath)
{
String P = @" Http: // [^ \.] * \. (? <Domain> [^/] *) " ;
RegEx Reg = New RegEx (p, regexoptions. ignorecase );
Match m = Reg. Match (strhtmlpagepath );
Return M. Groups [ " Domain " ]. Value;
}
// Domain Name truncation (including second-level domain names)
Uri uritmp = New Uri ( @" Http://fff.sohu.com/newsecond/searchmore/bs-CS__address_sdf--1_ff=ffffssssss.htm " );
Response. Write (uritmp. Host. tostring ());
Other operations: Public String [] Geturlfolername ( String Strhtmlpagepath)
{
// Capture the file directory in the URL string
Int At = 0 ;
Int Start = 0 ;
Int Notei = 0 ;
Int Endi = 0 ;
Int [] Myintarray = New Int [ 10 ];
String [] Arrayfoldername = Null ;
String Newfoldername;
While (Start < Strhtmlpagepath. length) && ( > - 1 ))
{
At = Strhtmlpagepath. indexof ( ' / ' , Start );
If ( = - 1 ) Break ;
Myintarray [notei] = At;
Start = At + 1 ;
Notei = Notei + 1 ;
Endi = At;
}
Arrayfoldername = New String [Notei - 1 ];
For ( Int I = 0 ; I < Notei; I ++ )
{
If (Myintarray [I] > 0 )
{
If (Myintarray [I + 1 ] > 0 )
{
Newfoldername = Strhtmlpagepath. substring (myintarray [I] + 1 , Myintarray [I + 1 ] - Myintarray [I] - 1 );
Arrayfoldername. setvalue (newfoldername, I );
}
}
}
ReturnArrayfoldername;
}
Public String Geturlfilename ( String Strhtmlpagepath)
{
// Capture the file name in the URL string
Int At = 0 ;
Int Start = 0 ;
Int Notei = 0 ;
Int Endi = 0 ;
Int [] Myintarray = New Int [ 10 ];
String Newfilename = "" ;
While (Start < Strhtmlpagepath. length) && ( > - 1 ))
{
At = Strhtmlpagepath. indexof ( ' / ' , Start );
If ( = - 1 ) Break ;
Myintarray [notei] = At;
Start = At + 1 ;
Notei = Notei + 1 ;
Endi = At;
}
For ( Int I = 0 ; I < Notei; I ++ )
{
If (Myintarray [I] > 0 )
{
If (Myintarray [I + 1 ] = 0 )
{
Newfilename = Strhtmlpagepath. substring (myintarray [I] + 1 , Strhtmlpagepath. Length - Myintarray [I] - 1 );
}
}
}
ReturnNewfilename. tolower ();
}