Skip to content

Conversation

Meitoseshifu
Copy link
Contributor

No description provided.

Copy link
Contributor

@tboychuk tboychuk left a 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
Copy link
Contributor

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 {

/**
Copy link
Contributor

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
Copy link
Contributor

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();
}

/**
Copy link
Contributor

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();
}

/**
Copy link
Contributor

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.

Copy link
Contributor

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() {
Copy link
Contributor

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();
}

/**
Copy link
Contributor

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
Copy link
Contributor

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() {
Copy link
Contributor

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)" +
Copy link
Contributor

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?

@tboychuk tboychuk merged commit 4a111c1 into main Nov 5, 2021
@tboychuk tboychuk deleted the 112-crazy-regex-exercise branch November 5, 2021 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants