Check only existing first Numeric value

Viewed 40

I am performing filter and that filter options contain numeric and string. If the user clicks on # then it will display all prefix numeric values.

let filterValue = ["3D Amazon", "ABC", "5G", "Flip 3Te"]

The output will look like 3D Amazon and 5G

1 Answers

To display all prefix numeric values:

print(filterValue.filter{$0.first?.isNumber == true})

Output:

["3D Amazon", "5G"]
Related