Reuse Patterns Using Capture Groups Activity

In the ‘row’ example there is nothing alphanumeric about the string, so using ‘(\w+)’ behooves me to seek clarity. Can ‘[a-z]+’ also be a reference? Is it still permissible to use ‘(\w+)’, despite it’s alphabetical nature?

You need to include the link to the challenge so we know which one you are talking about.

Here you go Bruce:

If you know that the words in the string you are searching will only ever have the letters a-z then yes, you could use ([a-z]+). But this example doesn’t make that assumption, so it uses (\w+) to catch a broader range of characters.

Thank you. I am very grateful!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.