title: Sed - Replace last occurrence of match for each line
body: <p>So I have the following file:</p>
  
  <pre><code>Carlton 3053
  Carlton North 3054
  Docklands 3008
  East Melbourne 3002
  Flemington 3031
  Kensington 3031
  Melbourne 3000
  Melbourne 3004
  North Melbourne 3051
  St Kilda East 3183
  </code></pre>
  
  <p>I want to replace the last space just before the numbers with a hyphen, this is the closest I've got</p>
  
  <pre><code>cat file.txt | sed -r 's/\ /\-/g'
  </code></pre>
  
  <p>But this replaces all spaces with a -
  I want the output to look like this:</p>
  
  <pre><code>Carlton-3053
  Carlton North-3054
  Docklands-3008
  East Melbourne-3002
  Flemington-3031
  Kensington-3031
  Melbourne-3000
  Melbourne-3004
  North Melbourne-3051
  St Kilda East-3183
  </code></pre>
  
  <p>Any ideas?</p>