how to use the match function in javascript for regex
const str = 'For more information, see Chapter 3.4.5.1';
const re = /see (chapter \d+(\.\d)*)/i;
const found = str.match(re);
console.log(found);
// logs [ 'see Chapter 3.4.5.1',
// 'Chapter 3.4.5.1',
// '.1',
// index: 22,
// input: 'For more information, see Chapter 3.4.5.1' ]
// 'see Chapter 3.4.5.1' is the whole match.
// 'Chapter 3.4.5.1' was captured by '(chapter \d+(\.\d)*)'.
// '.1' was the last value captured by '(\.\d)'.
// The 'index' property (22) is the zero-based index of the whole match.
// The 'input' property is the original string that was parsed.
Also in JavaScript:
- function expression
- javascript detectar la pagina
- jsx full form
- javascript character ascii value modify
- javascript add day to date
- 3. What are private member variables. in js
- check if element is visible
- javascript turn string into array
- how to use the match function in javascript for regex
- convert csv to json powershell code
- javascript arrays codeburst
- document jquery
- how to include local image files in javascript object
- jquery alertify
- javascript get srollwidth
- Javascript remove array item by value
- js go back
- change style on click react
- prepend option on 2nd index jquery
- js make radio checked
- js retrieve form data
- jest async test fetch api
- how to solve Could not write JSON: Infinite recursion (StackOverflowError)
- convert data into json format in javascript