2016-07-08 3 views
1

vimeo URL에서 비디오 ID를 추출하고 싶습니다. 어떤 신체에서도 RegEx를 사용하면 도움이 될 수 있습니다.vimeo url objective-c에서 vimeo 비디오 ID를 추출하십시오. objective-c

동영상 URL이 그냥 샘플 URL입니다 유형

https://vimeo.com/173652088 

될 수 있습니다. RegEx는 모든 vimeo URL에 대해 작동해야합니다. 당신이 확실한 경우

+0

은 항상 끝에 오는 비디오 ID입니까? 또는 다른 형식이 될 수있는 것은 무엇입니까? – hariszaman

+0

예 비디오 ID는 항상 url.Ex-com/videoId – Developer

+0

끝 부분에 있습니다. 그렇다면 reg ex를 시도하는 이유는 URL이 동적 인 경우 –

답변

1

PLZ는 마지막에 있어야이 코드

NSString *yourStr = @"https://vimeo.com/173652088"; 
NSString *str = [yourStr stringByReplacingOccurrencesOfString: @"https://" withString:@""]; 

NSArray *arryVedios =[str componentsSeparatedByString:@"/"] ; 

NSString *id= [ arryVedios lastObject]; 
NSLog(@"id= %@",id); 

귀하의 ID url.but마다이 코드가 작동 해보십시오.

+0

은 "https://vimeo.com/173031270?a=1&b=2" – hariszaman

1
NSString *old = @"https://vimeo.com/173652088"; 
NSString *new = [old stringByReplacingOccurrencesOfString: @"https://vimeo.com/" withString:@""]; 
NSLog(@"new= %@", new); 

NSString *newone = [[old componentsSeparatedByString:@"/"] lastObject]; 
NSLog(@"newone= %@", newone); 

enter image description here

+0

문자열을 바꿔보십시오. 그러면 정규 표현식으로 바뀝니다. –

관련 문제