swift 中的 NSRegularExpressions 的 NSArray
NSArray of NSRegularExpressions in swift
分叉 here has a custom link function but the implementation in the actual code is in objective C.This 是代码行,她再次打印:
- (NSArray<NSRegularExpression*>*)getRegularExpressions
{
return [NSArray arrayWithObject:[NSRegularExpression regularExpressionWithPattern:@"#([a-zA-Z0-9])+" options:0 error:NULL]];
}
我想知道如何在 swift 中重现此内容,我已经放置了所有框架代码,我只需要知道如何执行此操作即可。
试试这个
func getRegularExpressions() -> [NSRegularExpression] {
var arrayOfExpressions = [NSRegularExpression]()
do
{
let expresion = try NSRegularExpression(pattern: "#([a-zA-Z0-9])+", options:.CaseInsensitive)
arrayOfExpressions.append(expresion)
}catch _
{
arrayOfExpressions.removeAll()
return arrayOfExpressions
}
return arrayOfExpressions;
}
希望对你有帮助
分叉 here has a custom link function but the implementation in the actual code is in objective C.This 是代码行,她再次打印:
- (NSArray<NSRegularExpression*>*)getRegularExpressions
{
return [NSArray arrayWithObject:[NSRegularExpression regularExpressionWithPattern:@"#([a-zA-Z0-9])+" options:0 error:NULL]];
}
我想知道如何在 swift 中重现此内容,我已经放置了所有框架代码,我只需要知道如何执行此操作即可。
试试这个
func getRegularExpressions() -> [NSRegularExpression] {
var arrayOfExpressions = [NSRegularExpression]()
do
{
let expresion = try NSRegularExpression(pattern: "#([a-zA-Z0-9])+", options:.CaseInsensitive)
arrayOfExpressions.append(expresion)
}catch _
{
arrayOfExpressions.removeAll()
return arrayOfExpressions
}
return arrayOfExpressions;
}
希望对你有帮助