Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The fork here has a custom link function but the implementation in the actual code is in objective C.This is the code line and her it is printed again:

- (NSArray<NSRegularExpression*>*)getRegularExpressions
{
   return [NSArray arrayWithObject:[NSRegularExpression regularExpressionWithPattern:@"#([a-zA-Z0-9])+" options:0 error:NULL]];
}

I was wondering how i could reproduce this in swift, I have already placed all of the framework code, I just need to know how to do this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
135 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this

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;
}

I hope this helps you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...