Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go

Idiom #168 Trim suffix

Create string t consisting of string s with its suffix w removed (if s ends with w).

import "strings"
t := strings.TrimSuffix(s, w)
using System;
string t = s.TrimEnd(w);

New implementation...
programming-idioms.org