Back to Type Challenges

README.Zh CN

questions/00116-medium-replace/README.zh-CN.md

latest1.7 KB
Original Source
<!--info-header-start--><h1>Replace </h1><blockquote><p>by Anthony Fu <a href="https://github.com/antfu" target="_blank">@antfu</a></p></blockquote><p><a href="https://tsch.js.org/116/play/zh-CN" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

实现 Replace<S, From, To> 将字符串 S 中的第一个子字符串 From 替换为 To

例如

ts
type replaced = Replace<'types are fun!', 'fun', 'awesome'> // 期望是 'types are awesome!'
<!--info-footer-start-->

<a href="../../README.zh-CN.md" target="_blank"></a> <a href="https://tsch.js.org/116/answer/zh-CN" target="_blank"></a> <a href="https://tsch.js.org/116/solutions" target="_blank"></a> <!--info-footer-end-->