1

I want to .search() for $( #nav ul li). The spaces should be regarded.

So far i got: (\s)*$(\s)*\((\s)*#nav(\s)+ul(\s)+li(\s)*\)(\s)*

(\s)*$ this part seems to works, and so does (\s)*\(

but if i put it together, it wont work. What am I missing?

Josh Crozier
  • 202,159
  • 50
  • 343
  • 273
ovih
  • 27
  • 3
  • possible duplicate of [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – Nathan Tuggy Feb 22 '15 at 02:27

1 Answers1

2

$ is a special character in regex which matches the end of the line boundary. You must need to escape that in-order to match a literal $ symbol.

(\s)*\$(\s)*\((\s)*#nav(\s)+ul(\s)+li(\s)*\)(\s)*

And remove the unnecessary groups.

\s*\$\s*\(\s*#nav\s+ul\s+li\s*\)\s*

DEMO

Avinash Raj
  • 160,498
  • 22
  • 182
  • 229