type TrimLeft<S extends string> = S extends ` ${infer R}`
? TrimLeft<R>
: S extends `\n\t${infer R}`
? TrimLeft<R>
: S
Solution by eunsukimme #35135
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer R}` ? TrimLeft<R> : S;
Solution by raeyoung-kim #35029
// 여기 풀이를 입력하세요
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer R}` ? TrimLeft<R> : S;
Solution by LeeKangHyun #34914
We can separate string with literal templates.
type TrimLeft<S extends string> = S extends `${' ' | '\t' | '\n'}${infer R}` ? TrimLeft<R> : S;
Solution by dev-jaemin #34884
// your answers
type TrimLeft<S extends string> = S extends `${" " | "\n" | "\t"}${infer R}`
? TrimLeft<R>
: S;
Solution by zeyuanHong0 #34835
type TrimLeft<T extends string> = T extends `${' ' | '\n' | '\t'}${infer Rest}` ? TrimLeft<Rest> : T;
Solution by semet #34678
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer R}` ? TrimLeft<R> : S
Solution by binhdv155127 #34644
type Space = ' ' | '\n' | '\t'
type TrimLeft<S extends string> = S extends `${Space}${infer R}` ? TrimLeft<R> : S
Solution by devshinthant #34571
// 你的答案
type Space = ' ' | '\n' | '\t'
type TrimLeft = S extends ${Space}${infer B}
?TrimLeft:S
Solution by W-fitTiger #34258
type TrimLeft<S extends string> = S extends `${' '|'\n'|'\t'}${infer rest}` ? TrimLeft<rest> : S
Solution by ouzexi #33993
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer U}` ? TrimLeft<U> : S
Solution by ScriptBloom #33895
type Space = ' ' | '\n\t'
type TrimLeft<T extends string> = T extends `${Space}${infer R}` ? TrimLeft<R> : T
Solution by Danny101201 #33844
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer Rest}`
? TrimLeft<Rest>
: S
Solution by laplace1009 #33721
type Space = '\t' | '\n' | ' '
type TrimLeft<S extends string> = S extends `${Space}${infer word}` ? TrimLeft<word> : S
Solution by loevray #33326
// 你的答案
type WhiteType = ' '|'\n'|'\t'
type TrimLeft<S extends string> = S extends `${WhiteType}${infer O}` ? TrimLeft<O> : S
Solution by walker-hzx #32937
// 解答をここに記入
type Space = ' '| '\n'|'\t';
type TrimLeft<S extends string> = S extends `${Space}${infer A}`
? TrimLeft<A>
: S;
型変数S
がスペースの後に文字列が来ているかどうかを判定し、スペースがあれば、TrimLeft
を再帰処理で動作させる。
\n
や\t
も含まれるため、Space
というユニオン型を定義し使用する。Solution by Yasunori-aloha #32882
type Space = "\n" | " " | "\t"
type TrimLeft<S extends string> =S extends `${Space}${infer R}` ? TrimLeft<R>: S;
Solution by bananana0118 #32753
type Space = ' ' | '\n' | '\t'
type TrimLeft<T extends string> = T extends `${Space}${infer S}` ? TrimLeft<S> : T
Solution by ZhulinskiiDanil #32675
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer Rest}` ? TrimLeft<Rest> : S
Solution by dev-hobin #32364
type EmptyCharacter =
| ' '
| '\n'
| '\t'
type TrimLeft<TData extends string> = TData extends `${infer LeftPad}${infer Content}`
? LeftPad extends EmptyCharacter
? TrimLeft<Content>
: TData
: TData
Solution by LwveMike #32244
// your answers
type TrimLeft<S extends string> = S extends `${' ' | '\n' |'\t'}${infer R}` ? TrimLeft<R> : S;
Solution by pea-sys #31946
type Space = ' ' | '\n' |'\t'
type TrimLeft<S extends string> = S extends `${Space}${infer R}` ? TrimLeft<R> : S;
Solution by kai-phan #31625
// your answers
type TrimLeft<S extends string> = S extends `${' ' | '\n' | '\t'}${infer Text}` ? TrimLeft<Text> : S;
Solution by LcsGa #31611
type Space = '\t' | '\n' | ' ';
type TrimLeft<S extends string> = S extends `${Space}${infer R}` ? TrimLeft<R> : S;
Solution by jinyoung234 #31606
// your answers
type TrimLeft<T extends string> = T extends ` ${infer Text}` ? TrimLeft<Text> : T;
Solution by AhmedRagabKamal #31495
type TrimLeft<S extends string> = S extends `${infer R}${infer U}`
? R extends " " | "\n" | "\t"
? TrimLeft<U>
: `${R}${U}`
: "";
Solution by vipulpathak113 #31417
type H<T extends string> = `\n${T}`|`\t${T}`|` ${T}`
type TrimLeft<S extends string> = S extends H<infer A> ? TrimLeft<A> : S;
Solution by eward957 #31228
type Space = ' ' | '\n' | '\t'
type TrimLeft<S extends string> = S extends `${Space}${infer R}` ? TrimLeft<R> : S
Solution by MyeonghoonNam #30927
type TrimLeft<S extends string> =
S extends `${infer R}${infer Rest}`
? R extends ' ' | '\n' | '\t'
? TrimLeft<Rest>
: S
: ''
Solution by GodAraden #30633
type TrimLeft<S extends string> = S extends `${ " " | "\n" | "\t" }${infer Rest}` ? TrimLeft<Rest> : S;
Solution by qiuye-zhou #30381