Horje
how to use the match function in javascript for regex Code Example
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.




Javascript

Related
sort array by field Code Example sort array by field Code Example
javascript upload file button Code Example javascript upload file button Code Example
vue router url string Code Example vue router url string Code Example
express multer Code Example express multer Code Example
autoplay is not working in in audio tag html Code Example autoplay is not working in in audio tag html Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7