diff --git a/02_Day/string_methods/match.js b/02_Day/string_methods/match.js index 6e281415..54e18a83 100644 --- a/02_Day/string_methods/match.js +++ b/02_Day/string_methods/match.js @@ -15,8 +15,8 @@ console.log(string.match(pattern)) // ["love", "love", "love"] // Let us extract numbers from text using regular expression. This is not regular expression section, no panic. let txt = 'In 2019, I run 30 Days of Pyhton. Now, in 2020 I super exited to start this challenge' -let regEx = /\d+/ // d with escape character means d not a normal d instead acts a digit +let regEx = /\d/g // d with escape character means d not a normal d instead acts a digit // + means one or more digit numbers, // if there is g after that it means global, search everywhere. -console.log(text.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"] -console.log(text.match(/\d+/g)) // ["2019", "30", "2020"] +console.log(txt.match(regEx)) // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"] +console.log(txt.match(/\d+/g)) // ["2019", "30", "2020"]