Beta
Replace the extension
Description:
We define a filename's extension as the substring following the last occurence of '.' in it.
Examples:
"file1.txt" -> "txt"
"file2.abc.ijk" -> "ijk"
"file3" -> ""
Your task is to implement the function replace_extension
.
This function replaces the string parameter's original extension with new_ext
, and returns the result:
* replace_extension("file", "txt") -> "file.txt"
* replace_extension("file.abc.markdown", "md") -> "file.abc.md"
* replace_extension("file.a.b.c.d.e.f.g.h.i", "a") -> "file.a.b.c.d.e.f.g.h.a"
* replace_extension("file.txt", "") -> "file"
* replace_extension(".file.hidden", "abc") -> ".file.abc"
Notes:
If any of the parameters is NULL, the function's output should be NULL.
Filenames which are not 'valid' (containing
\
,/
, or:
) should be treated, and the function must return NULL in such cases.
Strings
Fundamentals
Similar Kata:
Stats:
Created | Nov 4, 2017 |
Published | Nov 4, 2017 |
Warriors Trained | 183 |
Total Skips | 35 |
Total Code Submissions | 806 |
Total Times Completed | 37 |
C Completions | 37 |
Total Stars | 6 |
% of votes with a positive feedback rating | 83% of 29 |
Total "Very Satisfied" Votes | 19 |
Total "Somewhat Satisfied" Votes | 10 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 27 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |