Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whitespace handling in function regex #1

Closed
jonschlinkert opened this issue Mar 22, 2015 · 3 comments
Closed

whitespace handling in function regex #1

jonschlinkert opened this issue Mar 22, 2015 · 3 comments

Comments

@jonschlinkert
Copy link
Owner

Per regexhq/function-regex#2 (comment).

that regex shares several issues

@chocolateboy I think the first example you gave is potentially an issue, function foo () {} // > 1 space, but since the other is intentionally defined in the regex, [ \t], maybe that's more of a feature request given that it's not really a javascript parser, just code context?

@chocolateboy
Copy link

I'm not familiar with this package, so my comment may not be relevant if handling real-world code is out of scope.

But for anything beyond basic grepping, I recommend using a parser rather than regexes if you want to avoid playing whack-a-mole with edge cases. There's an Esprima-based function parser here.

@jonschlinkert
Copy link
Owner Author

if you want to avoid playing whack-a-mole with edge cases.

lol good line.

I recommend using a parser rather than regexes

I mostly use this for generating documentation. You're right though, I've played whack-a-mole with far too many edge cases. At some point I might start using a real parser even for the code comments since the use cases are getting more complex, but speed-wise real parsers are orders of magnitude slower and I haven't really had any problems with this yet.

good feedback though, thank you

@jonschlinkert
Copy link
Owner Author

closing since this hasn't really caused an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants