# 07. Remove All Occurrences of a Substring

### Remove Spaces

[Link](https://bit.ly/3sfP71Q)

```cpp
string replaceSpaces(string &str){
  int pos = string::npos;

  while((pos = str.find(' ')) != string::npos) 
    str.replace(pos, 1, "@40");
  
  return str;
}
```

### Remove Substring

[Link](https://leetcode.com/problems/remove-all-occurrences-of-a-substring/)

```cpp
string removeOccurrences(string s, string part) {
    int pos = string::npos;
    while((pos = s.find(part)) != string::npos) 
        s.erase(pos, part.length());
    return s;
}
```
