[英]NSRegularExpression pattern for ICECAST data
我正在嘗試使用NSRegularExpression從音頻流中創建ICECAST數據,但我認為我的模式存在一般性問題。
這是我的代碼:
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"StreamTitle='(.*)';"
options:NSRegularExpressionCaseInsensitive
error:nil];
NSMutableString *messageAsText = [NSMutableString stringWithUTF8String:[messageAsRawData bytes]];
NSTextCheckingResult *match = [regex firstMatchInString:messageAsText
options:0
range:NSMakeRange(0, [messageAsText length])];
NSString *message = [messageAsText substringWithRange:[match rangeAtIndex:1]];
NSLog(@"Input: '%@', Output: '%@'", messageAsText, message);
說輸入是:
StreamTitle='Thomas Newman - Awkward Talk [The Horse Whisperer]';StreamUrl='';
我希望得到這個:
Thomas Newman - Awkward Talk [The Horse Whisperer]
但我明白了:
Thomas Newman - Awkward Talk [The Horse Whisperer]';StreamUrl='
這與NSRegularExpression無關,因為如果在此處測試,正則表達式顯示相同的結果: http ://regex.larsolavtorvik.com/
有人能指出我正確的正則表達式嗎?
嘗試通過跟隨它來使*
quatifier懶惰?
像這樣:
StreamTitle='(.*?)'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.