Answers for "regex before and after character"

0

regex before and after character

const string = 'host_shopping.sql';
const regex = new RegExp('(?<=[_]).*(?=[\.])');

let regArray = regex.exec(	string	);
console.log(	regArray[0]	);
 
// shopping

console.log(	string.test(regex)	);
//true

/*
-> regex before & after character.
-> with no group and can find at 0 index.
-> lookbehind and lookahead must be supported where to use.
 */
Posted by: Guest on October-06-2021

Code answers related to "regex before and after character"

Code answers related to "Javascript"

Browse Popular Code Answers by Language