I have a div that I am trying to run a regular expression on
<div class="module-header-content module-default">
I am using this replace operation that used to work,but now that I have added the module-header-content class it becomes problematic
replace(/module-\w+/gi, ' ');
I need a regular expression that removes all instances of module- except for module-header-content
Any help.
Thanks
The entire call:
var $target = $(this).parent().parent().parent().parent();
//// Removes all module-xxxx classes
var classes = $target[0].className.replace(/module-\w+/gi, '');
You need a negative lookahead.
module-(?!header-content)\w+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With