Skip to content
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

[Learn]: Wrong description for lesson 56 #343

Open
amirhoseinsalimi opened this issue Mar 4, 2024 · 1 comment
Open

[Learn]: Wrong description for lesson 56 #343

amirhoseinsalimi opened this issue Mar 4, 2024 · 1 comment

Comments

@amirhoseinsalimi
Copy link

amirhoseinsalimi commented Mar 4, 2024

Step Number: 56
Step Name: steps.withoutNumberCharacter.title
Language: en (and maybe other translations)
Version: v2.29.0

User Agent:
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'


The description for the 56th example is:

Regex does a greedy match by default. This means that the matchmaking will be as long as possible. Check out the example below. It refers to any match that ends in r and can be any character preceded by it. But it does not stop at the first letter r.

However, the last sentence indicates that the RE does not stop at the first r while it should say it doesn't stop at the first e, confirming that the RE is greedy by default. The correct description would be:

Regex does a greedy match by default. This means that the matchmaking will be as long as possible. Check out the example below. It refers to any match that ends in r and can be any character preceded by it. But it does not stop at the first letter.

Alternatively this issue can be solved by changing the examples.

@CorbanPendrak
Copy link
Contributor

Hi there!

I understand the confusion from the description, but the text does mean what it says.

The greedy match /.*r/ will find the match that ends in the character 'r'. Thus, the greedy match is going until it finds the last 'r' in the text, in this case at the end. The confusion likely comes from the regular expression treating ber beer beeer beeeer as one occurrence, when we would normally want it to stop by word.

Do you think that a description like this would be clearer?

Regex does a greedy match by default, matching the longest possible subset. In this example, it refers to any match that ends in 'r', with any number of any characters preceding it. Since these character can include spaces and even the character 'r', the match extends to the final 'r' in the text.

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

No branches or pull requests

2 participants