Method 1: the most direct.
ns string * urlString = @ "/img/Baidu _ logo _ fqj _ 10 . gif ";
ns string * fileName =[urlString lastPathComponent];
NSLog(@“% @ "%@", file name);
Method 2: Segmentation by character or time series.
Object -C
ns string * link = @ "/img/Baidu _ logo _ fqj _ 10 . gif ";
ns string * filename =[[ns string alloc]init];
NSArray * separated array =[[NSArray alloc]init];
separated array =[link components separated bystring:@ "/];
filename =[separated array last object];
NSLog(@“% @”,separated array);
NSLog(@“% @ "%@", file name);
[File name publishing];
Method 3: treat the link as a path.
ns string * urlString = @ "/img/Baidu _ logo _ fqj _ 10 . gif ";
NSArray * urlCom =[[NSArray alloc]init with array:[URL path components]];
NSLog(@“% @”,[urlCom last object]);
[urlCom publishing];
Method 4: NSRange. It is very convenient to intercept binary files.
ns string * urlString = @ "/img/Baidu _ logo _ fqj _ 10 . gif ";
NSString * fileName
ns range range =[urlString range of string:@ "/" options:NSBackwardsSearch];
if (range.location! = NSNotFound)
{
fileName =[urlString substringromindex:range . location+ 1];
if([[fileName lower casestring]hasSuffix:@”。 gif"])
{
NSLog(@“% @ "%@", file name);
}
other
{
}
}
other
{
Return;
} & lt/pre & gt; & ltbr & gt
& ltbr & gt
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& lt/div & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; Z index: 9999; top:220 px; Left: 5px width:1px; Height: 1px ">
& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " alt = " " height = " 5 " width = " 77 " style = " position:absolute; Left:-77px; top:-5px " >& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >
& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;
& ltpre & gt& lt/pre & gt;
& ltdiv id = " live margins _ control " style = " position:absolute; z-index:9999 " >& ltimg src = " " height = " 5 " width = " 77 " alt = " " style = " position:absolute; Left:-77px; top:-5px " >
& ltimg src = " " alt = " " style = " position:absolute; Left: 0; top:-5px " >& ltimg id = " monitor-play-button " src = " " alt = " " style = " position:absolute; Left:1px; top:0 " >& lt/div & gt;