-
-
Notifications
You must be signed in to change notification settings - Fork 499
112 Create skeleton for regex #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu very nice exercise overall 👍
Please take a look and address my comments. Next time I guess it makes sense to create a completed PR as well.
# <img src="https://raw.githubusercontent.com/bobocode-projects/resources/master/image/logo_transparent_background.png" height=50/>Crazy Regex | ||
|
||
### Objectives | ||
You're supposed to know how to work regex and be able to build Patterns and Matchers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objectives mean the learning goals of this exercise. What you specified here is prerequisites
*/ | ||
public class CrazyRegex { | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu every javadoc starts from Create Pattern that accepts String with regex inside and can * find
which makes it redundant. You can simplify it, e.g. A pattern that finds a specific word.
* Create Pattern that accepts String with regex inside and can | ||
* find all words "Curiosity" in text | ||
* | ||
* @return Pattern with regex expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu it doesn't make sense to have the same
@return Pattern with regex expression
Let's replace it with @return a compiled Pattern instance that looks for the word "Curiosity"
or
@return a pattern that looks for the word "Curiosity"
throw new ExerciseNotCompletedException(); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu I believe it makes sense to provide some examples inside javadoc. A text and then what should be the result if you use this pattern to find the matches. In this method, I wasn't sure what means "all numbers". E.g. if I have in the text 25th of October
then should "25" be found or not? It can be explained in the example.
throw new ExerciseNotCompletedException(); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu since it's not necessarily clear what is a zip code, it would be nice to have an example here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or at least explanation: "a zip code is a 5-digit number without any characters or special symbols,"
|
||
@Test | ||
@Order(14) | ||
void findAbbreviation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu the test will pass with this regex [A-Z]{2}
. I'm not sure if this is what you've been looking for.
throw new ExerciseNotCompletedException(); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have an example.
* Create Pattern that accepts String with regex inside and can | ||
* find all http links inside () | ||
* | ||
* @return Pattern with regex expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu it would be good to have an example, because it's not clear why links are inside ().
|
||
@Test | ||
@Order(16) | ||
void findOnlyResources() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu why square brackets are also a part of the result? I guess we should find only the resource e.g. Google
, and not [Google]
.
@Order(17) | ||
void findOnlyLinksInNote() { | ||
String result = regexChecker(crazyRegex.findOnlyLinksInNote(), text); | ||
assertThat(result).isEqualTo("\n(https://google.com)\n(https://stackoverflow.com)" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meitoseshifu same here, why (https://google.com)
not https://google.com
?
No description provided.