```
import Foundation
//Functions
//An "amazingly elegant" way of using regex (Why does it need to be a [String], I just need the string!
func matches(of regex:String, in text:String) -> [String] {

    do {
        let regex = try NSRegularExpression(pattern: regex)
        let results = regex.matches(in: text, range: NSRange(text.startIndex..., in: text))
        return results.map {
            String(text[Range($0.range, in: text)!])
        }
    } catch let error {
        print("invalid regex: \(error.localizedDescription)")
        return []
    }
}
let fileName = #"[\w\s\,\.\-]+\.txt"#
let filePath = "/Users/Johnson/Some Text File.txt"
let funckWiktor = matches(of: fileName, in: filePath!)
print(funckWiktor)
//["Some Text File.txt"]

```

I would really love it if I could just get the string without the quotation marks. For example:

```
let fileName = #"[\w\s\,\.\-]+\.txt"#
let filePath = "/Users/Johnson/Some Text File.txt"
let funckWiktor = matches(of: fileName, in: filePath!)
print(funckWiktor)
//Some Text File.txt

```

I love the way we can replace regEx matches in Swift like so:

```
let stringOrg = "Hello, I just want the last part of this."
let regEx = #"\w\."#
var finalString = stringOrg.replacingOccurrences(of: regEx, with: "", options: .regularExpression)

```

And I wish there was a way to just find them similar to this:

```
let stringOrg = "Hello, I just want the last part of this."
let regEx = #"\w\."#
let incompleteString = "Something is missing at the end of "
var finalString = incompleteString + stringOrg.findingOccurrences(of: regEx, options: .regularExpression)
//[finalString = "Something is missing at the end of this."]

```

Is there a way to get the clean substring when matching with regEx?