Skip to content

Commit d12157a

Browse files
* docs: kata description * feat: kata/remove-anchor-from-url --------- Co-authored-by: ParanoidUser <[email protected]>
1 parent a653766 commit d12157a

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415
- [Regexp Basics - is it a six bit unsigned number?](regexp-basics-is-it-a-six-bit-unsigned-number "567e8dbb9b6f4da558000030")
416416
- [Regexp Basics - is it a vowel?](regexp-basics-is-it-a-vowel "567bed99ee3451292c000025")
417417
- [Regexp basics - parsing prices](regexp-basics-parsing-prices "56833b76371e86f8b6000015")
418+
- [Remove anchor from URL](remove-anchor-from-url "51f2b4448cadf20ed0000386")
418419
- [Remove consecutive duplicate words](remove-consecutive-duplicate-words "5b39e91ee7a2c103300018b3")
419420
- [Remove duplicate words](remove-duplicate-words "5b39e3772ae7545f650000fc")
420421
- [Remove the minimum](remove-the-minimum "563cf89eb4747c5fb100001b")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# [Remove anchor from URL](https://www.codewars.com/kata/remove-anchor-from-url "https://www.codewars.com/kata/51f2b4448cadf20ed0000386")
2+
3+
Complete the function/method so that it returns the url with anything after the anchor (`#`) removed.
4+
5+
## Examples
6+
7+
```
8+
"www.codewars.com#about" --> "www.codewars.com"
9+
"www.codewars.com?page=1" -->"www.codewars.com?page=1"
10+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata {
2+
static String removeUrlAnchor(String url) {
3+
return url.replaceAll("#.*", "");
4+
}
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class SolutionTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
www.codewars.com#about, www.codewars.com
10+
www.codewars.com/katas/?page=1#about, www.codewars.com/katas/?page=1
11+
www.codewars.com/katas/, www.codewars.com/katas/
12+
https://example.com#section1, https://example.com
13+
""")
14+
void sample(String url, String expected) {
15+
assertEquals(expected, Kata.removeUrlAnchor(url));
16+
}
17+
}

0 commit comments

Comments
 (0)