Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leta91/winter-is-coming-house-of-the-dragon
How to find characters with lazy matching
https://github.com/leta91/winter-is-coming-house-of-the-dragon
beginner-friendly fcc freecodecamp freecodecamp-challenge game-of-thrones gameofthrones got house-of-the-dragon houseofthedragon javascript js regular-expression regular-expressions winteriscoming
Last synced: 6 days ago
JSON representation
How to find characters with lazy matching
- Host: GitHub
- URL: https://github.com/leta91/winter-is-coming-house-of-the-dragon
- Owner: leta91
- License: mit
- Created: 2022-09-25T10:44:12.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-25T10:57:32.000Z (over 2 years ago)
- Last Synced: 2024-12-02T00:35:41.163Z (2 months ago)
- Topics: beginner-friendly, fcc, freecodecamp, freecodecamp-challenge, game-of-thrones, gameofthrones, got, house-of-the-dragon, houseofthedragon, javascript, js, regular-expression, regular-expressions, winteriscoming
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Find Characters with Lazy Matching (freeCodeCamp Challenge)
Inspired by Game of Thrones, House of The Dragon sequel ❄️🔥## "Regular Expressions" ➡️ Chapter 3
## Part of the JavaScript Certification ➡️ Lesson 14### In regular expressions there are 2 types of matches:
1. greedy match (by default) = it finds the *longest possible* part of a string that matches the regex pattern
2. lazy match = it finds the *shortest possible* part#### Complete the Challenge:
Fix the regex `/<.*>/` to return the HTML tag `` and not the text `"
Winter is coming
"`Initially we have `let myRegex = /<.*>/;` that we have to change
let's analyze the solution `/.h[0-9]*?>/`
- wildcard `.` corresponds to any character
- [0-9] any number between 0 and 9 to follow the letter `h`
- `?` corresponds to lazy matching that ends with this character `>`