How is this regex wrong?

Posted by Spot on Stack Overflow See other posts from Stack Overflow or by Spot
Published on 2010-12-28T20:49:28Z Indexed on 2010/12/28 20:53 UTC
Read the original article Hit count: 140

Filed under:

I have a regex which I'm using to match user functions inside an IDE (Sublime). This matches what I want (the function name itself), but it also matches the first parentheses. Therefore the match is like follows:

this._myFunction('content');

Notice the opening paran.

Here is my expression:

(?:[^\._])?([\w-]+)(?:[\(]){1}

How can I exclude the opening paran from getting matched?

.

As a bonus question: How can I successfully not match the string: function, because as you can expect function( matches (not fun in JS).

Thank you to anyone who can assist.

© Stack Overflow or respective owner

Related posts about regex