std.replace_prefix

STRINGstd.replace_prefixSTRINGsSTRINGtargetSTRINGreplacement

Available inall subroutines.

Replaces the literal string target in string s with replacement if s begins with that prefix.

This corresponds to std.prefixof(s, target) returning true. If pattern is the empty string, the original string s is returned.

Example

std.replace_prefix("0xABCD1234", "0x", "") # returns "ABCD1234"

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)