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

Idiom #167 Trim prefix

Create string t consisting of string s with its prefix p removed (if s starts with p).

let t = s.trim_left_matches(p);
import std.string;
string t = s.chompPrefix(p);
import "strings"
t := strings.TrimPrefix(s, p)
uses StrUtils;
if AnsiStartsStr(p, s) then 
  t := copy(s, length(p)+1, length(s)-length(p))
  s := t;
t = s.split(p, 1)[-1]
t = s.sub(/\A#{p}/, "")
t = s.delete_prefix(p)

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Related idioms