Answers for "js regex match all occurrences"

0

get all matches regex javascript

var re = /s*([^[:]+):"([^"]+)"/g;
var s = '[description:"aoeu" uuid:"123sth"]';
var m;

do {
    m = re.exec(s);
    if (m) {
        console.log(m[1], m[2]);
    }
} while (m);
Posted by: Guest on June-19-2021
0

javascript regex all matches match

let array = [...str.matchAll(regexp)];

array[0];
// ['test1', 'e', 'st1', '1', index: 0, input: 'test1test2', length: 4]
array[1];
// ['test2', 'e', 'st2', '2', index: 5, input: 'test1test2', length: 4]
Posted by: Guest on July-22-2021
0

javascript regex One or more occurrences of the pattern

// Regular expression 1 or more occurrences of the pattern
console.log(/'d+'/.test("'123'")); // true
console.log(/'d+'/.test("''")); // false

let cartoonCrying = /boo+(hoo+)+/i;
console.log(cartoonCrying.test("Boohoooohoohooo"));// true
Posted by: Guest on June-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language