why does this regular expression always return null?

poeveadastuse

New Member
This question already has an answer here: I need to check for classname in a string.My string looks like this:\[code\]testing ui-li ui-li-static ui-btn-up-f ui-first-child ui-filter-hidequeue\[/code\]And I'm looking for \[code\]ui-filter-hidequeue\[/code\] anywhere (!) in the string.This is what I'm trying. It always returns \[code\]null\[/code\], althought the string I'm trying to match is there:\[code\]var classPassed = 'ui-filter-hidequeue', classes = 'testing ui-li ui-li-static ui-btn-up-f ui-first-child ui-filter-hidequeue', c = new RegExp('(?:\s|^)' + classPassed + '(?:\s|$)');console.log( classes.match(c) ) // returns null\[/code\]Question:
Can someone tell me what I'm doing wrong in my regex?Thanks!
 
Back
Top