Question: convert a regular expression to all possible cases 

For Example:

1.9856[1-4] then it should return values like 98561,98562,98563,98564

2.98[4-5]65 then it should return values 98465,98565

Answer: 
You can first create a struct with codable to match your json format

```
struct CountryModel: Codable{
let flag: String
let country: String
let countryName: String

 }

```

And json read file as 

```
func readJson(){
    if let path = Bundle.main.path(forResource: "sample", ofType: "json") {
        do {
            let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
            let decoder = JSONDecoder()
            do {
   // get the data from JSON file with help of struct and Codable 
                let countryModel = try decoder.decode([CountryModel].self, from: data)
   // from here you can populate data in tableview
                print(countryModel)

            }catch{
                print(error) // shows error
                print("Decoding failed")// local message
            }

        } catch {
            print(error) // shows error
            print("Unable to read file")// local message
        }
    }
}

```
Use following code

```
class DummyDataModel {
var flag:String?
var country:String?
var countryName:String?
static func setingModelValues(_ values: JSON)->DummyDataModel {
    let dataModel = DummyDataModel()
    dataModel.flag = values["flag"].stringValue
    dataModel.country = values["country"].stringValue
    dataModel.countryName = values["countryName"].stringValue
    return dataModel
}}

class SampleClass: UIViewController {

@IBOutlet weak var mainTableView: UITableView! {
    didSet {
        mainTableView.delegate = self
        mainTableView.dataSource = self
        mainTableView.estimatedRowHeight = 200
        mainTableView.rowHeight = UITableView.automaticDimension
    }
}
var dummyDataModel = [DummyDataModel]()

override func viewDidLoad() {
    super.viewDidLoad()
    self.gettingJsonDataValue()

}
private func gettingJsonDataValue() {
    if let path = Bundle.main.path(forResource: "sample", ofType: "json") {
        do {
            let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
            let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
            let jsonResponse = try JSON(data: data)
            for myData in jsonResponse.arrayValue {
                let instadata = DummyDataModel.setingModelValues(myData)
                self.dummyDataModel.append(instadata)
            }
            self.mainTableView.reloadData()

        } catch {
            // handle error
        }

    }}
extension SampleClass: UITableViewDelegate,UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dummyDataModel.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let sampleCell = tableView.dequeueReusableCell(withIdentifier: "SampleCell") as! SampleCell
        sampleCell.gettingUiUpdate(dummyDataModel[indexPath.row])
        return sampleCell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }
    }

```