What is the correct syntax for defining the beginning and end of a a regex word as the boundary in a capture group as follows:
var $classes = $( 'body' ).attr('class'); // string 'foo bar sub-theme-home';
var regex = /sub-theme-(?=(\b))/;
var sub_theme = regex.exec($classes);
console.log(sub_theme[0]);
This is matching sub-theme- and while it’s fine if I need to include that in my capture and do string replacement to remove it, I’m having trouble figuring out the proper syntax for my (?-(\b))/ capture group. Seems like with positive lookahead, sub-theme- should be the omitted portion and home should be captured… help?
Why not just capture the string you’re looking for?
See more about parenthesized substrings and the result of
regex.exec(...)at MDN.