An open API service indexing awesome lists of open source software.

https://github.com/sustainable-git/coding-test


https://github.com/sustainable-git/coding-test

baekjoon-online-judge cheatsheet codility hackerrank programmers-online-judge

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Swift Algorithm

## Contents

### String
- Adding
```swift
var sample = "Hello"
sample += " World" // sample == "Hello World"
sample.append("!") // sample == "Hello World!"
```
- Accessing String Element
```swift
let name = "Marie Curie"
let firstSpace = name.firstIndex(of: " ") ?? name.endIndex
let firstName = name[..

### Regular Expression

```swift
func isMatched(target: String, pattern: String) -> Bool {
let patternString = "^" + pattern.replacingOccurrences(of: "*", with: "[a-zA-Z0-9]") + "$" // "^": start, "$": end
let regex = try? NSRegularExpression(pattern: patternString)
return regex?.firstMatch(in: target, options: [], range: NSRange(location: 0, length: target.count)) != nil
}
```