---
title: "removeSubranges(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/rangereplaceablecollection/removesubranges(_:)"
---

# removeSubranges(_:)

Removes the elements at the given indices.

## Declaration

```swift
mutating func removeSubranges(_ subranges: RangeSet<Self.Index>)
```

## Parameters

- `subranges`: The indices of the elements to remove.

## Discussion

Discussion For example, this code sample finds the indices of all the vowel characters in the string, and then removes those characters. var str = "The rain in Spain stays mainly in the plain." let vowels: Set<Character> = ["a", "e", "i", "o", "u"] let vowelIndices = str.indices(where: { vowels.contains($0) })

str.removeSubranges(vowelIndices) // str == "Th rn n Spn stys mnly n th pln." note: O(n), where n is the length of the collection.
