File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed
Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 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 ")
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 1+ interface Kata {
2+ static String removeUrlAnchor (String url ) {
3+ return url .replaceAll ("#.*" , "" );
4+ }
5+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments