I have the following style string passed in:
<p><iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F79039882"></iframe></p>
and
<p><iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F82229979&color=ff6600&auto_play=true&show_artwork=true"></iframe></p>
I require to filter out the strings "79039882" or "82229979" from the given strings.
Currently I am using the following code:
NSString * temp1;
NSScanner *scanner = [NSScanner scannerWithString:label];
[scanner scanUpToString:@"%2Ftracks%2F" intoString:nil];
[scanner scanString:@"%2Ftracks%2F" intoString:nil];
[scanner scanUpToString:@"&" intoString:&temp1];
Unfortunately it fails on the strings that are formatted as the first is. How would I be able to account for both types?
When the first style of string is passed in the temp1 result is this following:
79039882"></iframe></p>
Since you want only digits, use an
NSCharacterSet
that describes that, along withscanCharactersFromSet:intoString: