Day-2 String Methods - match()
Author: khari-onCreated Jun 12, 2022Updated Jul 2, 2025
let txt = 'In 2019, I ran 30 Days of Python. Now, in 2020 I am super exited to start this challenge' let regEx = /\d+/
console.log(txt.match(regEx)) - // ["2", "0", "1", "9", "3", "0", "2", "0", "2", "0"]
Ans for this match -
[2019, index: 3, input: "In 2019, I ran 30 Days of Python. Now, in 2020 I am super exited to start this challenge", groups: undefined]
It returns a array with the first match in regex
Source: Asabeneh/30-Days-Of-JavaScript