Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression to Exclude First Item

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, '');
like image 378
Seth Duncan Avatar asked Jan 20 '23 22:01

Seth Duncan


1 Answers

You need a negative lookahead.

module-(?!header-content)\w+

like image 67
masher Avatar answered Jan 30 '23 18:01

masher