Search code examples
regexack

Ack "unmatched ( in regex" error


I am really confused by this:

I am trying to ack for all calls to a JavaScript function hideSideBar(arg1, arg2, etc..) in my project.

Because it can optionally be called with no arguments, I started by just looking for instances of hideSideBar(

ack hideSideBar\(
error: Unmatched ( in regex ...

I am very confused, because I am escaping the left-paren... so why is it looking for a closing parenthesis?

(I am aware I could use a wildcard and do ack hideSideBar\(.*\) to get what I'm looking for. I'm more interested in understanding why what I attempted to do doesn't work.

Thanks!


Solution

  • If you type ack hideSideBar\( in the terminal,
    the shell will remove the \ and pass hideSideBar( to ack.

    So hideSideBar\( should be enclosed in '...'(or "..."),
    the shell will remove the quotes and pass hideSideBar\( to ack.