Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 15th, 2013  |  syntax: None  |  size: 1.56 KB  |  views: 517  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <iframe width="1280" height="720" src="http://www.youtube.com/embed/Pb55ep-DrSo?wmode=opaque&autoplay=1&fs=1&feature=oembed&showinfo=0&autohide=1&controls=0" frameborder="0" allowfullscreen></iframe>
  2.        
  3. NSString* str = @"<iframe width="1280" height="720" src="http://www.youtube.com/embed/Pb55ep-DrSo?wmode=opaque&autoplay=1&fs=1&feature=oembed&showinfo=0&autohide=1&controls=0" frameborder="0" allowfullscreen></iframe>";
  4. str = [str substringFromIndex:[str rangeOfString:@"src=""].location+[str rangeOfString:@"src=""].length];
  5. str = [str substringToIndex:[str rangeOfString:@"""].location ];
  6. NSLog(@"Str %@",str);
  7.        
  8. 2012-08-17 09:16:55.285 TEST[24413:c07] Str http://www.youtube.com/embed/Pb55ep-DrSo?wmode=opaque&autoplay=1&fs=1&feature=oembed&showinfo=0&autohide=1&controls=0
  9.        
  10. src[s]*=[s]*"([^"]*)"
  11.        
  12. NSString *searchedString = @"<iframe width="1280" height="720" src="http://www.youtube.com/embed/Pb55ep-DrSo?wmode=opaque&autoplay=1&fs=1&feature=oembed&showinfo=0&autohide=1&controls=0" frameborder="0" allowfullscreen></iframe>";
  13. NSError* error = nil;
  14.  
  15. NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"src[s]*=[s]*"([^"]*)"" options:0 error:&error];
  16. NSArray* matches = [regex matchesInString:searchedString options:0 range:NSMakeRange(0, [searchedString length])];
  17. for ( NSTextCheckingResult* match in matches )
  18. {
  19.     NSString* matchText = [searchedString substringWithRange:[match range]];
  20.     NSLog(@"match: %@", matchText);
  21.     NSRange group1 = [match rangeAtIndex:1];
  22.     NSLog(@"group1: %@", [searchedString substringWithRange:group1]);
  23. }