Files
.github
api-server
client
config
curriculum
docs
guide
arabic
chinese
english
3d
accessibility
agile
algorithms
android-development
angular
apache
aspnet
bash
blender
blockchain
bootstrap
bsd-os
bulma
c
canvas
certifications
apis-and-microservices
coding-interview-prep
data-visualization
front-end-libraries
information-security-and-quality-assurance
javascript-algorithms-and-data-structures
basic-algorithm-scripting
basic-data-structures
basic-javascript
debugging
es6
functional-programming
intermediate-algorithm-scripting
javascript-algorithms-and-data-structures-projects
object-oriented-programming
regular-expressions
check-for-all-or-none
check-for-mixed-grouping-of-characters
extract-matches
find-characters-with-lazy-matching
index.md
find-more-than-the-first-match
find-one-or-more-criminals-in-a-hunt
ignore-case-while-matching
match-a-literal-string-with-different-possibilities
match-all-letters-and-numbers
match-all-non-numbers
match-all-numbers
match-anything-with-wildcard-period
match-beginning-string-patterns
match-characters-that-occur-one-or-more-times
match-characters-that-occur-zero-or-more-times
match-ending-string-patterns
match-everything-but-letters-and-numbers
match-letters-of-the-alphabet
match-literal-strings
match-non-whitespace-characters
match-numbers-and-letters-of-the-alphabet
match-single-character-with-multiple-possibilities
match-single-characters-not-specified
match-whitespace
positive-and-negative-lookahead
remove-whitespace-from-start-and-end
restrict-possible-usernames
reuse-patterns-using-capture-groups
specify-exact-number-of-matches
specify-only-the-lower-number-of-matches
specify-upper-and-lower-number-of-matches
use-capture-groups-to-search-and-replace
using-the-test-method
index.md
index.md
responsive-web-design
index.md
chef
clojure
cloud-development
codeigniter
computational-genomics
computer-hardware
computer-science
containers
cplusplus
csharp
css
d3
data-science-tools
design-patterns
designer-tools
developer-ethics
developer-tools
devops
dns
docker
documentation
drupal
electron
elixir
elm
erlang
fsharp
game-development
gatsbyjs
git
go
graphql
groovy
haskell
haxe
hibernate
html
ionic
java
javascript
joomla
jquery
julia
kotlin
laravel
linux
logic
machine-learning
mariadb
mathematics
meta
miscellaneous
mobile-app-development
mongodb
natural-language-processing
neovim
network-engineering
nginx
nodejs
optical-alignment
php
powershell
product-design
progressive-web-apps
puppet
python
r
raspberry-pi
react
react-native
redux
rest-api
robotics
rt-os
ruby
rust
sass
security
semantic-ui
software-engineering
sql
ssh
svg
svn
swift
terminal-commandline
tomcat
tools
typescript
typography
user-experience-design
user-experience-research
vagrant
vim
virtualbox
visual-design
voice
vue
vue-cli
web-augmented-reality
web-components
web-performance
web-virtual-reality
wordpress
working-in-tech
xml
portuguese
russian
spanish
mock-guide
tools
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.node-inspectorrc
.prettierrc
.snyk
.travis.yml
.vcmrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.md
README.french.md
README.italian.md
README.md
docker-compose-shared.yml
docker-compose.yml
lerna.json
netlify.toml
package-lock.json
package.json
sample.env

16 lines
422 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Find Characters with Lazy Matching
---
## Find Characters with Lazy Matching
#### Challange:
Fix the regex `/<.*>/` to return the HTML tag `<h1>` and not the text `<h1>Winter is coming</h1>`. Remember the wildcard . in a regular expression matches any character.
#### Solution:
```js
let text = "<h1>Winter is coming</h1>";
let myRegex = /<h1>?/; // it's the answer!
let result = text.match(myRegex);
```