Reputation: 9017
see on jsfiddle. http://jsfiddle.net/yNJKj/13/
This regex is supposed to show only top level items. but it somehow sohws 2nd level items in SOME categories.
WHat am I doing wrong? Thanks!
Upvotes: 0
Views: 64
Reputation: 42496
My guess is it's this part, at the end of the regex:
\/.*[a-zA-Z]$
You're telling it to match the following:
/
I'm not 100% on what you are and aren't trying to match, but that wildcard part (.*
) is probably matching all the things you want, as well as what you don't. Making the regex more specific could help.
On an unrelated note, it would probably be more semantic and easier to work with if, instead of a single unordered list and
, you reworked it to utilize nested lists. Something like this:
<ul>
<li>
<a href="*">Category</a>
<ul>
<li><a href="*">Sub-Category</a></li>
<li><a href="*">Sub-Category</a></li>
</ul>
</li>
</ul>
However, if you do decide to stick with the non-breaking spaces, then couldn't you use those to decide what gets hidden? It looks like all you would have to do is hide anything that starts with
, and that would accomplish what you want.
Upvotes: 1
Reputation: 2312
I think you should change regexp to /^.*\/activity\/[a-zA-Z]*$/i
, because .
matchs all characters including /
Upvotes: 0
Reputation: 1074198
I think the regex you want is:
/^.*\/activity\/[^/]*$/i
Or possibly
/^.*\/activity\/[^/]*[a-zA-Z]$/i
(I'm not sure why you have that single-character [a-zA-Z]
match at the end.)
Your original
/^.*\/activity\/.*[a-zA-Z]$/i
...allows /
to be matched by the .*
preceding your [a-zA-Z]
, hence including sub-categories.
Upvotes: 5