2018-10-12 16:35:31 -04:00
|
|
|
---
|
|
|
|
|
title: Find Characters with Lazy Matching
|
|
|
|
|
localeTitle: العثور على شخصيات مع مطابقة كسول
|
|
|
|
|
---
|
|
|
|
|
## العثور على شخصيات مع مطابقة كسول
|
|
|
|
|
|
|
|
|
|
#### تحدي دبي:
|
|
|
|
|
|
|
|
|
|
أصلح regex `/<.*>/` لإرجاع علامة HTML `<h1>` وليس النص `<h1>Winter is coming</h1>` . تذكر حرف البدل. في التعبير العادي يطابق أي حرف.
|
|
|
|
|
|
|
|
|
|
#### حل:
|
|
|
|
|
|
2019-06-20 14:07:46 -07:00
|
|
|
```js
|
|
|
|
|
let text = "<h1>Winter is coming</h1>";
|
|
|
|
|
let myRegex = /<h1>?/; // it's the answer!
|
|
|
|
|
let result = text.match(myRegex);
|
|
|
|
|
```
|